What are the key knowledge of PHP?
This article mainly explains "what are the key knowledge of PHP". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the key knowledge of PHP"?
Tell me what you know about session and cookie.
Cookie is saved on the client and session on the server
For the implementation of session, you need to create a sesssionId on the client's cookie for association.
How to modify the Lifetime of SESSION
In fact, Session also provides a function session_set_cookie_params (); to set the lifetime of Session, this function must be called before the session_start () function is called
/ / Save for one day
$lifeTime = 24 * 3600
Session_set_cookie_params ($lifeTime)
Session_start ()
$_ SESSION ["admin"] = true
Sharing problems of session in distributed applications
The load mode of nginx is: ip_hash (allocates back-end servers according to ip)
Store the session value in (database, redis, memcache) and use session_id for associative queries.
Encrypt the session value DES into cookie. When the B server finds that there is no session, it will check whether the cookie exists.
Cross-domain sharing of session
Just set the domain of session and cookie to "primary domain". You can call the code to solve the problem
Session_set_cookie_params (1800,'/', '.mydomain.com'); at this point, I believe you have a deeper understanding of "what are the key knowledge of PHP". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!