How to redirect the users to their id specific urls/landing pages after they log in?

半腔热情 提交于 2019-12-03 09:14:23

Just append the user id from your $_SESSION to the URL you're redirecting to.

header('Location: user.php?id=' . $_SESSION['user_id']);

When you are checking for a successful log in, return the user's id in your query. Here's some quick pseudocode:

  • In query: Select user_id where user_name = ? and password=?
  • If results.count = 1 then store the user_id as $user_id
  • Redirect to "www.anysite.com/anydirectory/user.php?id=" . $User_Id
Rajeev Roy

Would you like to redirectjust like this :-

www.anysite.com/anydirectory/user.php?id=1

then only do

header("Location: user.php?id=".$userId);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!