nbaztec Posted August 16, 2011 Share Posted August 16, 2011 To start off, I was designing a site in PHP 5.3.5, I wrote the following code: //test_login.php session_start(); . . if([test credentials]) $_SESSION['user'] = '1'; else //Do Stuff //File_2.php if(!isset($_SESSION)) session_start(); echo $_SESSION['user']; echo $_SESSION['user']; echo $_SESSION['user']; Now on my localhost(PHP 5.3.5), it correctly outputs: 111 But when I put the same script on my webserver (PHP 5.2.3), the same script shows output: 011 It's as if the reference to $_SESSION['user'] isn't made until it's referenced for the 2nd time. Can anyone kindly enlighten me on this issue. Regards, Nisheeth Barthwal Quote Link to comment https://forums.phpfreaks.com/topic/244923-strange-php-session-behavior/ Share on other sites More sharing options...
nbaztec Posted August 16, 2011 Author Share Posted August 16, 2011 Solved. Issue with mysql_real_escape_string(). My bad. Quote Link to comment https://forums.phpfreaks.com/topic/244923-strange-php-session-behavior/#findComment-1258182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.