Jump to content

Session problem


rward

Recommended Posts

Hi,

I am wondering if anybody can help here. basically what i want to do is at the start of my site check if the sessions are set and if not set them. My problem is that on calling the following snippet of code it processes the first time but does not actually assign the  var 'session_id' until after a refresh or hitting the home page link that first calls this function.

Which results further down the line as two entrys into my database first one blank and second one with the 'session_id' var correctly.

 

if (!isset($_SESSION['session_id'])) {

session_start();

$_SESSION['session_id'] = $PHPSESSID;

 

...save to database the variable session_id....

}

 

Regards

Rob

Link to comment
Share on other sites

Yes I had tried this first and after different tests the condition was posted as previous but its the same effect.

 

session_start();

 

if (!isset($_SESSION['session_id'])) {

$_SESSION['session_id'] = $PHPSESSID;

 

...save to database the variable session_id....

}

Link to comment
Share on other sites

scottybwoy,

This helps in the way that only one entry is saved to the DB until reloading the browser but the session ID itself is still not saved to the database or the variable 'session_id'. Could you elaborate on your answer.

Cheers

Rob

Link to comment
Share on other sites

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.