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 is the life cycle of PHP5 Session?

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

What is the life cycle of PHP5 Session? in view of this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

PHP5 has a lot to learn. Here we mainly introduce the use of PHP5 Session. How does Session judge client users? It is judged by Session ID, what is Session ID, that is, the file name of the Session file, Session ID is randomly generated, so it can ensure * and randomness, and ensure the security of Session. In general, if the life cycle of the Session is not set, the Session ID is stored in memory, and the ID is automatically logged out after closing the browser. After re-requesting the page, re-register a Session ID.

If the client does not disable Cookie, Cookie plays the role of storing the Session ID and Session lifetime when starting the Session session. Let's manually set the lifetime of Session:

In fact, PHP5 Session also provides a function session_set_cookie_params (); to set the lifetime of PHP5 Session, this function must be called before the session_start () function is called:

If the client uses IE 6. 0, the session_set_cookie_params (); function will have some problems setting up the Cookie, so we'll call the setcookie function manually to create the cookie. What if the client disables Cookie? No way, all lifecycles are browser processes, as long as you close the browser and re-request the page to re-register Session. So how to pass Session ID? Through URL or by hiding the form to pass, PHP will automatically send Session ID to URL, URL is like: http://www.openphp.cn / index.php?PHPSESSID=bba5b2a240a77e5b44cfa01d49cf9669, where the parameter PHPSESSID in URL is Session ID, we can use $_ GET to get the value, so as to achieve the transfer between Session ID pages.

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

Development

Wechat

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

12
Report