i am building a php based website but now i need to give user a session, i.e the user can log in to website and have his session. after he should signout. how can i achieve this.?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could have a $_SESSION[“auth”] = true once the user logs in and the script which verifies the password should usually set the above session variable . then redirect to a restricted-to-members page like dashboard.php or photos.php using header(). Once the user logs out you should use session_destroy() function. Also its safer to have a session_regenerate_id(true) on every page so the session id cookie regenerated to prevent session hijacking.