我在PHP里用了session_start(),出现了异常

来源:百度知道 编辑:UC知道 时间:2024/05/06 05:07:10
出现这样:

Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in c:\Inetpub\wwwroot\sjk\check.php on line 2
管理员帐户名正确!
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\Inetpub\wwwroot\sjk\check.php:2) in c:\Inetpub\wwwroot\sjk\check.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at c:\Inetpub\wwwroot\sjk\check.php:2) in c:\Inetpub\wwwroot\sjk\check.php on line 20

第一个错误是说在会话初始化之前,调用了session_destroy();
第二个错误是说,在初始化会话之前有页面输出。

所以,应该把 session-start() 放在文件开头,并保证之前没有任何输出,哪怕是一个空格。

这样试试看……

要放在文件头 楼上确实没有说错!
同类我知道的还有那个转向页面的函数也是