Home  >  Article  >  Backend Development  >  一个session的报错问题 很简单 谁帮忙解释下

一个session的报错问题 很简单 谁帮忙解释下

WBOY
WBOYOriginal
2016-06-20 12:35:461111browse

( ! ) Notice: A session had already been started - ignoring session_start() in D:\php2\wamp\www\shop\top.php on line 2
Call Stack
# Time Memory Function Location
1 0.0010 177552 {main}( ) ..\index.php:0
2 0.0020 183496 include( 'D:\php2\wamp\www\shop\top.php' ) ..\index.php:8
3 0.0020 183528 session_start ( ) ..\top.php:2

谁可以帮忙解释下这个报错说的是什么意思 第一行是说session重复启用吗   那下面几行什么 time 什么memory 这些具体说什么
怎么处理 谢谢大家


回复讨论(解决方案)

之所以出现这种情况是页面中多次使用了 session_start()函数
有以下两种解决办法:
1) in php.ini file set session.autostart to 0 配置php.ini 设置session.autostart =0
session.auto_start = 0
2) In your code use this line 在出现错误的页面中编辑你的代码如下:
if (!session_id()) session_start();
instead of
session_start();

之所以出现这种情况是页面中多次使用了 session_start()函数
有以下两种解决办法:
1) in php.ini file set session.autostart to 0 配置php.ini 设置session.autostart =0
session.auto_start = 0
2) In your code use this line 在出现错误的页面中编辑你的代码如下:
if (!session_id()) session_start();
instead of
session_start();

那请问下面几行说的是什么意思啊

标志你调用的位置

你最好是把 session_start() 写在一个方法里面,在里面判断是否开启了 session ,以后就调用那个方法设置/调用session就行了

下面几行也是说你重复调用了 session_start() 

A session had already been started - ignoring session_start() 
session_start()  被重复执行了
这是 php5.4 加入的错误警告,很不友好!
@session_start() ;
屏蔽掉就可以

下面是 xdebug 给出的调用栈信息
Time 自开始执行的时间,单位:秒
Memory 内存使用量,单位:字节
Function 执行的函数
Location 所在文件:行

你重复调用了 session_start() 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn