runnerjp Posted March 3, 2016 Share Posted March 3, 2016 The sessions on my server are being written but are not getting read the following code used: <?phpsession_start();if (isset($_POST['submit'])) {if(!isset($_SESSION['cheese'])) {$_SESSION['cheese'] = 1;} else {$_SESSION['cheese']++;}}?> session_start() creates new session on page reload meaning its not picking up the session. The above code displays no value. php ini file looks like this for sessions: Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted March 3, 2016 Share Posted March 3, 2016 The code doesn't display anything, so what exactly makes you think that sessions aren't resumed? Execute this script twice and show us each response: <?php session_start(); echo 'Cookies:<br>'; var_dump($_COOKIE); echo '<br>'; echo 'Session:<br>'; var_dump($_SESSION); $_SESSION['test-8165'] = 'test'; Also check the PHP error log. Quote Link to comment Share on other sites More sharing options...
benanamen Posted March 3, 2016 Share Posted March 3, 2016 Depending on the name of a button to be submitted will completely fail under certain circumstances. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 3, 2016 Author Share Posted March 3, 2016 Cookies: array(0) { } Session: array(0) { } is displayed both times... but if i go into the session temp file in server i see : test-8165|s:4:"test"; Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 3, 2016 Author Share Posted March 3, 2016 also in logs i have found Session Cache is not configured [hint: SSLSessionCache] Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted March 3, 2016 Share Posted March 3, 2016 The browser doesn't even send the session cookie, so PHP has no chance of resuming the session. Does your browser block cookies from the domain of your application? Have you tried a different browser? Quote Link to comment Share on other sites More sharing options...
JeremyBenson11 Posted March 6, 2016 Share Posted March 6, 2016 (edited) If you're navigating to other pages you need session_start() at the top of them too if you're going to access session data. Session start doesn't just start a new session, but allows you to access the variables in your server. index.php session_start(); $_SESSION['hello'] = 'Hi, there!'; echo '<a href="show.php">Click Me!</a>'; show.php session_start(); echo $_SESSION['hello']; When you load index you'll get a hello message set to hello index in $_SESSION. When you navigate to show.php you will see the message. Edited March 6, 2016 by JeremyBenson11 Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted March 6, 2016 Share Posted March 6, 2016 This has nothing to do with the problem at hand. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted March 6, 2016 Share Posted March 6, 2016 Are cookies disabled on your browser? If so, enable them. If not, try the following: <?php session_start(); echo('session_name(): <pre>'.print_r(session_name(),1).'</pre>'); echo('session_id(): <pre>'.print_r(session_id(),1).'</pre>'); echo('session_get_cookie_params(): <pre>'.print_r(session_get_cookie_params(),1).'</pre>'); echo('$_COOKIE: <pre>'.print_r($_COOKIE,1).'</pre>'); echo('$_SESSION: <pre>'.print_r($_SESSION,1).'</pre>'); $_SESSION['test']=time(); Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 6, 2016 Share Posted March 6, 2016 the OP's symptom is most probably due to php not being able to send the session cookie to the browser. the session data file is still created in this instance. does the OP have php's error_reporting set to E_ALL and display_errors set to ON in the php.ini on his development system so that php would report and display all the errors it detects, particularly a couple of warnings at the session_start() statement? Quote Link to comment 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.