Home > Article > Backend Development > How to hide parameters in php address bar
How to hide parameters in the php address bar: first save the uid into the session after the user logs in; then give the user the session ID; finally, determine and display the currently logged in user information in "userinfo.php".
Recommended: "PHP Video Tutorial"
Question:
The page I made with PHP, if you click on a user to view the user information, the following will appear on the URL bar: http://www.abc.com/index.php?user_id=39. You can view other users by modifying the number. .
Solution:
//首先,你得在用户登录后把uid存到session里,比如在login.php中 $_SESSION['uid'] = XXX //XXX为用户登录时给他的sessionID(和user表的uid值相同) //比如在userinfo.php中 if($_SESSION['uid'] == intval($_GET['user_id'])){ //显示当前登录用户信息 }else{ //可以显示别的用户的信息(用$_SESSION['uid']查询user表的uid,并根据需要展示信息) //也可以直接给出error信息,告诉他不能查看该用户的信息 }
The above is the detailed content of How to hide parameters in php address bar. For more information, please follow other related articles on the PHP Chinese website!