开发者

PHP Session Variables Undefined Errors

I've been experiencing a very frustrating problem with a administrative website I have recently developed. I have error handling set to email myself, and randomly I receive multiple 'Error: [8] Undefined index: username' messages whilst the system is in use. I have been unabl开发者_开发知识库e to identify the precise actions that trigger these errors however. Also, these messages aren't visible when error handling is set to echo, and the functionality of the site isn't affected.

It seems to me that the problem was caused by the session timing out, and the site not handling this correctly. However, when a login is left for a period of time then refreshed it does indeed redirect to the login page as expected with no errors.

Included at the very top of every page is:

session_start();

Next is the error handling code. This is then followed by the security code of which the first check is:

if(isset($_SESSION['loggedin']) and isset($_SESSION['username'])) {

if this fails, session_destroy(); is called and it redirects to the login page.

I cannot work out why I still keep receiving

> Error: [8] Undefined index: username'

emails when an isset check is in the header of every page! The irregularity of these errors are making it impossible for me to debug.

Any insight into what might be the issue would be very much appreciated! Many Thanks :)


Try adding to your debug code. Make your debug emails also send you the output of a debug_backtrace call at the time the file is output. This way you can see the exact path taken to get from the outermost script, to the line where the error is occurring.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜