两次使用session_start [英] Using session_start twice

查看:125
本文介绍了两次使用session_start的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很愚蠢的问题(我相信):

I have a pretty dumb question (I believe):

如果我要开始2个会话,两次调用session_start(),会发生什么情况?例如,我有一个User类,在其中启动用户的会话,而有一个Error类,在其中启动另一个会话,因此我可以在其中存储错误和通知,并将它们传递给其他页面.

What would happen, if I were to start 2 sessions, calling session_start() twice? For example, I have a class User, where I start user's session, and a class Error, in which I start another session, so I can store errors and notifications in them and pass them to other pages.

我能遇到问题吗,这有效吗?

Could I run into a problem, and is this efficient?

推荐答案

PHP不支持多个同时会话.除非现有会话(通过session_destroy())被破坏,否则在请求中第二次调用session_start()不会执行任何操作.

PHP doesn't support multiple simultaneous sessions. Calling session_start() a second time in a request doesn't do anything unless the existing session was destroyed (via session_destroy()).

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.

http://php.net/session-start

这篇关于两次使用session_start的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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