dellwoodbu Posted February 9, 2009 Share Posted February 9, 2009 I am having what appears to be not an uncommon problem. I am using $_SESSION to store some user log in data mostly the fact that they have logged in and are validated. This works perfectly on localhost WAMP (vista, 2.2, 5.1x?, 5.2.4) but not at all on the remote linux server for now I only know linux, mysql 5.x and php5.1.x on the remote. I have included a session.php which has a session_start in each page. I have tried both header redirects, javascript self.location and manually clicking a link. All cause a new/different session to come into being on the remote side but all work on localhost. I have done the session_write_close(). Nothing seems to work. This is my first significant project with PHP so please be explicit. I am wondering if the fact that the database is not on the same machine this causes the server to think I am leaving the domain. The db is on a local intranet IP (10.x.x.x) (local to the remote linux box). However I can connect from home to the external IP address of the remote database and it works. I have checked phpinfo() on both local and remote hosts. Under the sessions section both are identical. If it can be easily found as a "solution" to this kind of problem on the internet I have probably tried it with no success. Please help. would like to demo Tuesday feb 10 09. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/ Share on other sites More sharing options...
dellwoodbu Posted February 9, 2009 Author Share Posted February 9, 2009 This occurs in both firefox3 and IE6. Both browsers work on local. Neither work on remote host. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-757923 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2009 Share Posted February 9, 2009 Add the following two lines of code immediately after your first opening <?php tag on all relevant pages - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-757931 Share on other sites More sharing options...
dellwoodbu Posted February 9, 2009 Author Share Posted February 9, 2009 I have added the code in the sessions.php file that gets included at the top of every page. it is the first thing after the <?php in that file. The result is exactly the same. ini_set ("display_errors", "1"); error_reporting(E_ALL); The problem is not a PHP error the problem is that PHP/the server is deciding I need a new session instead of continuing to use the existing one. I have read the php documentation virtually the whole section regarding sessions. Why does the remote server decide I need a new session? what can I do to prevent this behavior? Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758206 Share on other sites More sharing options...
premiso Posted February 9, 2009 Share Posted February 9, 2009 We need to see the code, also a better explanation would help. Are you trying to instantiate an old session? If so, the reason that would not work is cause session files are hosted on the server, hence remote and local would be different. Without code your problem will go unsolved. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758214 Share on other sites More sharing options...
dellwoodbu Posted February 9, 2009 Author Share Posted February 9, 2009 Attached is the code. the basic flow is this... user comes to login.php page. enters user name and pw in form. loginck.php is the submit action of that form. That page compares the login/pw to the values in the mysql db. if matches it sets $_SESSION vars and puts out a link to the member_home.php page. At one point I had a auto redirect (self.location=...) I would prefer that eventually but read elsewhere that may cause session problems. in top.php there is a check of session vars to insure logged in. if logged in a submenu appears on the page. The member_home.php page looks at the id of the person who logged in and prints a summary of information from the db that pertains to them. This uses the session var to do the sql query selecting this persons id. It will probably make more sense in the code. The only thing I have modifed is commented in sale_function.php. I intentionaly obscured the db server and user information. The link to the db is working, it is the session vars that are not being carried from one page to the next. Thanks again. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758379 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2009 Share Posted February 9, 2009 What does a phpinfo() statement show for register_globals? Edit: And please put the two lines I gave you for error reporting at the top of any relevant page, not in an include file. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758408 Share on other sites More sharing options...
dellwoodbu Posted February 9, 2009 Author Share Posted February 9, 2009 some warnings from the login page: Warning: Unknown: open(/var/lib/php/session /vservers/illinoismccreliefsale/tmp/sess_36c1678b1bb8f342f375b0db03a3be87, 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/lib/php/session /vservers/illinoismccreliefsale/tmp) in Unknown on line 0 Notice: Undefined index: isloggedin in /vservers/illinoismccreliefsale/htdocs/includes/top.php on line 10 Warning: Unknown: open(/var/lib/php/session /vservers/illinoismccreliefsale/tmp/sess_36c1678b1bb8f342f375b0db03a3be87, 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/lib/php/session /vservers/illinoismccreliefsale/tmp) in Unknown on line 0 From the loginck page the same warnings at the top about session_start() + Warning: session_write_close() [function.session-write-close]: open(/var/lib/php/session /vservers/illinoismccreliefsale/tmp/sess_36c1678b1bb8f342f375b0db03a3be87, O_RDWR) failed: No such file or directory (2) in /vservers/illinoismccreliefsale/htdocs/members/includes/loginck.php on line 35 Warning: session_write_close() [function.session-write-close]: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session /vservers/illinoismccreliefsale/tmp) in /vservers/illinoismccreliefsale/htdocs/members/includes/loginck.php on line 35 similar warnings on the member_home page, with a undefined index for each time I try to use a session var. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758464 Share on other sites More sharing options...
dellwoodbu Posted February 9, 2009 Author Share Posted February 9, 2009 Forgot to mention register globals are OFF in all cases local and remote. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758465 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2009 Share Posted February 9, 2009 From the error, this is your session.save_path setting - /var/lib/php/session /vservers/illinoismccreliefsale/tmp/ Also from the error - No such file or directory Either that path does not exist or there is an error in it (there appears to be a space in it that is likely not present in the actual path.) Find and fix the problem with your session.save_path setting. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758469 Share on other sites More sharing options...
dellwoodbu Posted February 9, 2009 Author Share Posted February 9, 2009 Right on the money. You folks are wonderful. somehow someway the php.ini for my site had an extra space in the session.save_path I had to call tech support since I have only read access to the file but they were able to fix it and things appear now to be working well. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/144439-php-session-variables-localhost-works-remote-does-not/#findComment-758489 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.