PHP:会话变量 [英] PHP: Session variables
问题描述
我开始学习php.我有一个关于会话的问题.
I am beginning to learn php. I have a question regarding sessions.
现在,我知道 session_start()
创建了一个会话变量.
Right now, I know that session_start()
creates a session variable.
我不知道的是,当我访问我创建的会话时,是否需要再次使用session_start()
?
What I don't know is, when I access the session I created, do I need to use session_start()
again?
如果是...
这是为什么?因为我已经创建了一个会话,我想知道为什么它不会持续整个浏览会话.
Why is this? Because I already created a session and I wonder why it wouldn't last the entire browsing session.
推荐答案
因为我从中了解到,它将创建一个新会话.
because what i understand from it is, that it is going to create a new session.
否:
session_start()
基于通过 GET 或 POST 请求传递的会话标识符创建会话或恢复当前会话,或通过 cookie.
session_start()
creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.
您访问的每个新页面都是 PHP 的全新上下文.session_start
允许您重新建立之前的上下文/会话/数据.
Each new page you visit is an entirely new context for PHP. session_start
allows you to reestablish a previous context/session/data.
这篇关于PHP:会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!