sunwukung Posted January 8, 2009 Share Posted January 8, 2009 Hi, can any of you help me with this problem? I have recently moved to Linux hosting, but develop locally using WAMP. I'm having trouble trying to replicate session behaviour on my host - namely the session cookie appears to be empty when I leave one page and move to the next. For example - I set the session variable thus: session_start; $user_input='blah'; $_SESSION['data']=$user_input; and then on the next page I use the following: session_start; if ($_SESSION['data']=='blah'){ $x=$_SESSION['data']; echo "$x";} else { echo "errors"; } This is actually a much simpler description of what I'm doing - but in essence it's the same. When I test this locally I get the expected result - in this example the text 'blah' in the browser. However, when I test on the host, I get the error message. I did a print_r() of the $_SESSION variable on each location, and locally it reads out the content of the variable, but on the host the variable is empty once it is picked up by the recieving page. I've contacted my host, but they suggested that this might be down to the dev environment, specifically the variable 'path' on account of my local setup being windows, and the host being Linux. I checked the settings with phpinfo() on both environments, and under the session section there are the following differences: session.bug_compat_42: Host = On Local = Off session.gc_divisor: Host = 100 Local = 1000 session.hash_bits_per_character: Host = 4 Local = 5 session.save_path: Host = No value Local = C:/Program Files/wamp/tmp Link to comment https://forums.phpfreaks.com/topic/139944-solved-php-sessions-not-working-on-linux-host/ Share on other sites More sharing options...
Maq Posted January 8, 2009 Share Posted January 8, 2009 For starters it's: session_start(); Link to comment https://forums.phpfreaks.com/topic/139944-solved-php-sessions-not-working-on-linux-host/#findComment-732200 Share on other sites More sharing options...
sunwukung Posted January 8, 2009 Author Share Posted January 8, 2009 Sorry, that was a typo when writing the question for this forum: Anything else? Link to comment https://forums.phpfreaks.com/topic/139944-solved-php-sessions-not-working-on-linux-host/#findComment-732201 Share on other sites More sharing options...
sKunKbad Posted January 8, 2009 Share Posted January 8, 2009 Is there any chance that you are overlooking a character out of place in your real code? If we can look at it, we might be able to point out a mistake. I guess if it works on your home server, then there's really no reason it shouldn't work on the hosted server. I would do a little more testing, and then switch hosts. You shouldn't have to deal with irritating stuff like this. Link to comment https://forums.phpfreaks.com/topic/139944-solved-php-sessions-not-working-on-linux-host/#findComment-732207 Share on other sites More sharing options...
sunwukung Posted January 8, 2009 Author Share Posted January 8, 2009 Problem solved: i've used use ini_set to change the session.save_path Link to comment https://forums.phpfreaks.com/topic/139944-solved-php-sessions-not-working-on-linux-host/#findComment-732243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.