bournerj Posted February 14, 2011 Share Posted February 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/ Share on other sites More sharing options...
Bottyz Posted February 14, 2011 Share Posted February 14, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/#findComment-1174037 Share on other sites More sharing options...
bournerj Posted February 14, 2011 Author Share Posted February 14, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/#findComment-1174042 Share on other sites More sharing options...
Jessica Posted February 14, 2011 Share Posted February 14, 2011 My first though is it probably has to do with $_SERVER['HTTP_ACCEPT_ENCODING'] What do you get in the problematic situation if you do var_dump($_SERVER) and look for that key? (HTTP_ACCEPT_ENCODING) Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/#findComment-1174117 Share on other sites More sharing options...
bournerj Posted February 14, 2011 Author Share Posted February 14, 2011 I get: ["HTTP_ACCEPT_ENCODING"]=> string(38) "deflate, gzip, x-gzip, identity, *;q=0" Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/#findComment-1174129 Share on other sites More sharing options...
bournerj Posted March 1, 2011 Author Share Posted March 1, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/#findComment-1181275 Share on other sites More sharing options...
bournerj Posted March 1, 2011 Author Share Posted March 1, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/227617-strange-_session-data-problem/#findComment-1181284 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.