Answer the question
In order to leave comments, you need to log in
Question about cookies and sessions in php?
The session exists until the browser is closed. Everything is clear here, the question about the session is only this:
1. The session hash can be saved in the database
UPDATE `user` SET `session`=$session_hash WHERE `login`=$login
but why? The user closes the browser, what is the meaning of the remaining session in the database? Site on 1 server, i.e. it is not necessary to carry session between servers. array(2) {
["PHPSESSID"]=>
string(26) "ma7emp7j7vp6o85oqlclefi315"
["namecookie"]=>
string(5) "login"
}
Answer the question
In order to leave comments, you need to log in
How are cookies different from a session in PHP?
in addition:
- sessions can simply be stored in the database and then session handling is your concern. This is convenient when we have several servers and the balancer spreads us to different servers, then we have a single session center, for example. For the same purposes, you can use memcache or redis.
- sessions do not necessarily die after closing the browser
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question