mattachoo Posted May 19, 2009 Share Posted May 19, 2009 I've worked with sessions before in PHP. All of a sudden, they stopped working. My webhost recently did this "migration" thing where they changed a bunch of stuff (like upgrading from PHP 4 to PHP 5, etc.). Now, sessions don't work at all. I tried a simple test to see if they worked, and guess what, they don't. Here is my example: <?php //first_page.php session_start(); print("<html><pre>"); $_SESSION["MyLogin"] = "FYICenter"; print("A value saved in the session named as MyLogin.\n"); $_SESSION["MyColor"] = "Blue"; print("A value saved in the session named as MyColor.\n"); print("Click <a href=next_page.php>Next Page</a>" ." to retrieve the values.\n"); print("</pre></html>\n"); ?> <?php //next_page.php session_start(); print("<html><pre>"); $myLogin = $_SESSION["MyLogin"]; print("Value of MyLogin has been retrieved: ".$myLogin."\n"); $myColor = $_SESSION["MyColor"]; print("Value of MyColor has been retrieved: ".$myColor."\n"); print('</pre><a href="first_page.php">Click here to go back</a></html>\n'); ?> When I run the script, here is what I get in return: Value of MyLogin has been retrieved: Value of MyColor has been retrieved: Click here to go back\n Absolutely nothing. So my question is, what could be preventing my sessions from working? Also, when I click on the next_page.php link, it transfers a ?PHPSESSID variable in the URL. Maybe this has something to do with the problem? I don't know. Any help will be appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Try turning error reporting on at the top of your script that attempts to utilize sessions: error_reporting(E_ALL); Report back, here, whatever errors are printed. Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837044 Share on other sites More sharing options...
matto Posted May 19, 2009 Share Posted May 19, 2009 Could also be worth placing the following file on your host provider to see what the configuration looks like - just look for the session details <?php phpinfo(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837122 Share on other sites More sharing options...
mrMarcus Posted May 19, 2009 Share Posted May 19, 2009 have you contacted your host .. should be the first thing you do. there's a good chance they have somebody there who knows a thing or two about PHP. and i'm sure they'll be more than happy to assist you since you are paying them, no? perhaps it's just your session path that's changed? could be a number of things. Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837172 Share on other sites More sharing options...
JD* Posted May 19, 2009 Share Posted May 19, 2009 Also, this may sound stupid, but did you try using single quotes for your session defines instead of double? Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837355 Share on other sites More sharing options...
DarkSuperHero Posted May 19, 2009 Share Posted May 19, 2009 As JD said might be some odd behaviour dealing with magik quotes? (I really don't know). - have made it a habit to favor single quotes in my php code.... Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837358 Share on other sites More sharing options...
mattachoo Posted May 19, 2009 Author Share Posted May 19, 2009 Ah ha! Ok, I'm getting somewhere. It was suggested to me that I put ini_set("display_errors", "1"); error_reporting(E_ALL); at the start of my code. Now I get two error messages when I run my script. Warning: Unknown: open(/var/php_sessions/sess_2a6b97f59f33efcf2366295b4e204ba5, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/php_sessions) in Unknown on line 0 So what should I set the session.save_path to in the ini file? I am going to talk to customer support today. Hopefully they will be able to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837456 Share on other sites More sharing options...
Daniel0 Posted May 19, 2009 Share Posted May 19, 2009 That's your host's fault. Just get them to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/158711-sessions-dont-work-at-all/#findComment-837468 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.