Jump to content

Strange $_SESSION data problem


bournerj

Recommended Posts

Hi folks,

 

I have an initial redirect page which directs to my main page, sending two reference variables as $_GET parameters:

 

header("Location: /ob/index.php?id=".$id."&ref=".$ref);

 

The first thing this main page does is include a file which checks for those two values:

 

if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
session_start();
error_reporting(E_ALL);

if (isset($_GET['id']) && isset($_GET['ref'])){
$_SESSION['id'] = $_GET['id'];
$_SESSION['ref'] = $_GET['ref'];
}
if(!isset($_SESSION['id']) || $_SESSION['id']=="" || !isset($_SESSION['ref']) || $_SESSION['ref']==""){
echo ("This service requires a valid ID to run - your session may have expired, please refresh your browser to try again.");
exit;
}

 

The main page loads fine - meaning that the $_SESSION variables have been set correctly. However, when the next page loads (including the same file), the $_GET values obviously aren't there but the $_SESSION variables should be intact. I am getting fails every time though in Opera and Safari (have checked in IE, FF and Chrome and all seems well).

 

However, if I then refresh the browser - in both Opera and Safari - the next page loads fine and the $_SESSION variables are correctly set.

 

Any ideas on this at all?

 

Many thanks in advance,

 

Rich

Link to comment
Share on other sites

Silly question (Which is not usually browser specific but thought i'd throw the thought out there) but do you have the session start statement at the top of the next php file?

 

session_start();

 

Is Opera & Safari caching differently to the other browsers?

Link to comment
Share on other sites

Hi,

 

Yes, that same snippet is the first thing included by all of my pages so the session has definitely been started.

 

I don't know to be completely honest, I haven't changed anything from the default install of either.

 

I'm using IE 9 beta (which works fine) but on IE 8 am getting the same error - on a different PC.

Link to comment
Share on other sites

  • 2 weeks later...

Bump.

 

Does anybody have any further input on this problem?

 

Really strange - I don't understand why it would lose the data.

 

In Opera when I get to the second page (where the data is lost), and refresh the page using F5 - the session data magically reappears!

Link to comment
Share on other sites

Interestingly, I've just done some tests and my first page has a different session ID to the second page.

 

When I F5 refresh on the second page I am redirected (correctly) to the first page, where the session ID has now been set as the one from the second page and the variables I need setting are set and all is well!

 

Very confused now.

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.