解决Undefined variable: _SESSION的方法
(2013-04-11 17:10:10) | from:http://blog.sina.com.cn/s/blog_67140b580100ki0d.html from:http://blog.sina.com.cn/s/blog_6adbb77c0101cr7u.html |
本文为大家介绍解决PHP使用SESSION报错的方法。对于初次使用session的人来说可能会遇到Undefined variable: _SESSION这样的错误,错误原因是因为没有开启session。因为php中的session默认是不开启的,需要在程序中开启才能使用。PHP错误:PHP Notice: Undefined variable: _SESSION原因及解决方法
遇到Undefined variable: _SESSION 错误的原因是php session没有开启引起的。
下面有两种解决办法.
1. 在程序里添加session_start()函数
2.在php.ini里将session.auto_start = 0设置为session.auto_start = 1
以上就是解决Undefined variable: _SESSION的方法。
出处:http://www.phpbest.com/html/content-9-377-1.html
Notice: A session had already been starte解决办法
Notice: A session had already been started – ignoring session_start() in .. on line ..
This happens when you try to start session more than once.
The solution for above problem is
1) in php.ini file set session.autostart to 0
session.auto_start = 0
2) In your code use this line
if (!session_id()) session_start();
instead of
session_start();