I want my users to have secure session on my website. What must i store in cookie to recognise each use开发者_StackOverflow中文版r? Every time user logs in, cookie value must be changed. P.S. I want to make a database with cookie values which link to user id.
a session id?
You should store a session ID in the cookie. That said, you should NOT have to do this yourself. Use PHP sessions, it does all the cookie handling for you.
Why do you need to store the session IDs in a database? If you need semi-temporary data to travel with the user during their session, you can use the $_SESSION
variable for that. It is documented as part of the guide above.
PHP does not have native support for storing session IDs on the server in a database, you would have to write that yourself, or use a library that already provides that functionality, like CakePHP.
A cookie should be a cryptographic nonce that is used to reference server side state. IE: A session id. All web application platforms have their own session handler. In php you just call session_start()
and then use the $_SESSION[]
super global.
精彩评论