php 怎么知道开始一个新的会话 [英] How does php know to start a new session

查看:35
本文介绍了php 怎么知道开始一个新的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果浏览器关闭并重新打开,PHP 将启动一个新会话.

PHP will start a new session if a browser is closed and reopened.

旧会话文件仍保留在会话保存目录中,但启动了新会话.

The old session file is still kept in the session save directory, but a new session is started.

php 在浏览器中寻找什么才能知道它必须启动一个新会话?

What does php look for in the browser to know that it must start a new session?

我想我真正要问的是 session_start() 到底做了什么

I guess what i am really asking is, what exactly does session_start() do under the hood

推荐答案

为了简单地回答您的问题,它会查找名为 PHPSESSID 并且如果请求中没有提供 cookie,则调用 session_regenerate_id 用于初始化 cookie 值.

To simply answer your question, it looks for a cookie called PHPSESSID and if no cookie is supplied in the request, a call to session_regenerate_id is made to initialize the cookie value.

cookie 会在浏览器的整个生命周期内持续使用.

The cookie is then persistently used throughout the lifetime of the browser.

除非应用其他设置,否则这是默认行为的精简版本.

Unless other settings apply, this is a stripped down version of the default behavior.

这篇关于php 怎么知道开始一个新的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆