I can't find a fitting article 开发者_如何学JAVAfor this subject. Indeed, there are a lot of those I found, but they are old. How should I store session? How can I secure them, as much as possible, etc.
Those on php.net are updated. It's very easy to use sessions, you just (before any ouput) add this snippet of code session_start()
and then assign whatever you want to $_SESSION variable.
The short answer is, don't store sessions. The session_start()
and $_SESSION
variable should be all you need. If you need data to persist consider using either cookies or store the corresponding data in a local database which relates to a certain registered user.
Sessions are being used in order to "pass" data which is stored in $_SESSION variables. The data you can store in those variables can be username that's being saved after successful log in , or another information you find important becuase you might use it more than once.
In order to start session you use the session_start() function, and in order to create a new session variable you use $_SESSION['sessionName']=$var;
精彩评论