Jump to content

Recommended Posts

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,

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?

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.

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]

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.

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.