Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the key knowledge of PHP?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report