![]() |
PHP Sessions Question
Scenario: A user number 5884 into their account and edits there profile. The url is www.site.com/profile.php?id=5884. However, when they change the url to www.site.com/profile.php?id=5885 they can view the personal details of profile 5885.
What php session script (or other) do I put at the top of the viewprofile.php scripting to allow the logged in user to view only his/her profile? |
session variables are stored in the $_SESSION array. you probably know this. and you probably know to store the user id for the person in a session variable?
when someone messes with the url id number, they are changing the variable of $_GET['id'] in your script....so to make it where they can only view their own profile just do something such as if ($_SESSION['id'] hahahaha $_GET['id']) { echo 'all good now';} |
if ($_SESSION['id'] hahahaha $_GET['id'])
{ echo 'allow viewing'; } else { echo 'fuck off lamer'; } |
apparently two equal signs in a row is banned and replaced with hahahaha
|
Sounds good, I will give it a whirl! Thank you
|
To avoid that problem instead of using the $_GET["id"] just send them to profile.php and have it call the data using the session var, or if you don't want to be lazy and change what you have now (and this is bad form but it works :)):
PHP Code:
|
All times are GMT -7. The time now is 02:25 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123