未定义变量会话
我像这样使用 php $_SESSION
$_SESSION['original_referrer_location']
但我不断收到此错误,
Notice: Undefined variable: _SESSION in /var/www/m/inc/referrer.php on line 3
因此我将其添加到脚本的顶部
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(0, '/');
session_start();
,一切都很好。
有没有办法永久打开会话,因为必须将其添加到任何需要会话的脚本之上有点多余......我去了 php.ini 但有很多以会话开头的调用......关于我需要改变什么的任何想法......我在 ubuntu 10.10/php5 以防万一
I am using php $_SESSION like this
$_SESSION['original_referrer_location']
but i keep getting this error
Notice: Undefined variable: _SESSION in /var/www/m/inc/referrer.php on line 3
so I added this to the top of my script
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(0, '/');
session_start();
and all is good.
Is there a way to turn on sessions for good because having to add this on top of any script that needs a session is kind of redundant....i went to php.ini but there are many calls that start with session...any ideas on what i need to change ...I am on ubuntu 10.10/php5 in case that matters
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有:
http://www.php。 net/manual/en/session.configuration.php#ini.session.auto-start
但我不建议使用它。例如,您想在会话中存储整个对象,为此,您需要首先包含带有类声明的文件,否则未序列化的对象将属于不完整的类。
另一种方法是 auto-prepend 文件,设置一些基本配置并启动会议
There is:
http://www.php.net/manual/en/session.configuration.php#ini.session.auto-start
But i wouldn't recommend using it. For example you would like to store whole object in session, to do it you would need to include file with class declaration first, otherwise unserialized object will be of incomplete class.
Other way is to auto-prepend file that sets some basic configuration and starts session
是
session.auto.start
Yes
session.auto.start
当你想使用session时,记得在HTML标签之前调用session_start()
When you want to use sessions, remember to call session_start() before the HTML tag