I have a web app in which after user is logged in, he/she has cookie set for username set by setcookie().
Please suggest better approach for security.
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.
Use PHP sessions instead of cookies. The session variables are server-side. PHP will automatically handle the session management. You can also overload its functionality if you want more control.
http://php.net/manual/en/intro.session.php
With PHP-sessions, only a session identifier is stored in the browser cookies. You can store any information in the superglobal variable
$_SESSION, and the browser will not be able to see or tamper with these variables.For extra safety, you should store the remote address that was used to login, and compare it on each page load. This is to make sure that nobody hijacked the session id and is pretending to be logged in from another location.
To see if a user is logged in.