
write to a cookie
Code: Select all
setcookie("user", $username, time()+604800); /* Expires in a week */
Code: Select all
$user = $HTTP_COOKIE_VARS["user"];
Code: Select all
setcookie("user", $username, time()+604800); /* Expires in a week */
Code: Select all
$user = $HTTP_COOKIE_VARS["user"];
also with Seers method ensure that the $username is gathered from a cookie read or a $_REQUEST['username'] else you are vulnerable to SQL insertion.MSDN wrote: Use Cookies Securely
Cookies are an easy and useful way to keep user-specific information available. However, because cookies are sent to the browser's computer, they are vulnerable to spoofing or other malicious use. Follow these guidelines:
Do not store any critical information in cookies. For example, do not store a user's password in a cookie, even temporarily. As a rule, do not store any sensitive information in a cookie that. Instead, keep a reference in the cookie to a location on the server where the information is located.
Set expiration dates on cookies to the shortest practical time you can. Avoid permanent cookies if possible.
Consider encrypting information in cookies.
Consider setting the Secure and HttpOnly properties on your cookies to true.