[SOLVED...]lost sessions after redirect
Moderator: General Moderators
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
[SOLVED...]lost sessions after redirect
i've just been looking at why my session data is not being retained after a redirect. however session info has been retained in other parts of my site after a redirect, why is it now being lost?
it is happening in the course of three pages
search.php to search_process.php - sessions passed ok
search_process.php to search_results.php - no sessions passed
any ideas??
thanks
rj
it is happening in the course of three pages
search.php to search_process.php - sessions passed ok
search_process.php to search_results.php - no sessions passed
any ideas??
thanks
rj
Last edited by rubberjohn on Tue Apr 18, 2006 11:16 am, edited 1 time in total.
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
the whole code is too long but the relevant bits are
on the search page
$_SESSION['my_search_box'] can then be access in search_process.php, also in search_process.php i declare
at the end of the script.
Then when I echo $_SESSION['leaf_match'] or $_SESSION['sub_top_match'] nothing is echoed and when i use session_is_registered on them it returns FALSE. I have also tried session_write_close();
is it because the session variables in search_process.php are declared just before the redirect?
thanks rj
on the search page
Code: Select all
if(isset($_POST['search'])){
if(isset($_SESSION['my_search_box'])){
header('Location: http://www.merseysideemploymentlaw.co.u ... ocess.php');
exit;
}else{
echo "Please choose a tag before trying to search";
}
}$_SESSION['my_search_box'] can then be access in search_process.php, also in search_process.php i declare
Code: Select all
$_SESSION['leaf_match'] = serialize($arr_leaf_match);
$_SESSION['sub_top_match'] = serialize($arr_topic_match);
header("Location:
http://www.merseysideemploymentlaw.co.u ... s.php?.sid)");
exit;Then when I echo $_SESSION['leaf_match'] or $_SESSION['sub_top_match'] nothing is echoed and when i use session_is_registered on them it returns FALSE. I have also tried session_write_close();
is it because the session variables in search_process.php are declared just before the redirect?
thanks rj
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
if session_write_close() isn't working try
Code: Select all
$_SESSION['leaf_match'] = serialize($arr_leaf_match);
$_SESSION['sub_top_match'] = serialize($arr_topic_match);
header('Location: http://www.merseysideemploymentlaw.co.u ... ults.php?' . session_name() . '=' . session_id());
exit;-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
do i need to use that sess_id to reinitiate the sessions in search_results?
if not that doesn't work either - i think it is because the session initialisation is so close to the redirect - if a create a dummy session and place it near the redirect, it doesn't work but i put it at the top of the script it does work
rj
if not that doesn't work either - i think it is because the session initialisation is so close to the redirect - if a create a dummy session and place it near the redirect, it doesn't work but i put it at the top of the script it does work
rj
Can you post the top of the script as well please?
Try replacing this:
With this:
Try replacing this:
Code: Select all
header("Location: http://www.merseysideemploymentlaw.co.u ... s.php?.sid)");Code: Select all
header("Location: http://www.merseysideemploymentlaw.co.u ... ts.php?SID)");-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
no that didn't work - what do mean top of the script?
if you mean the dummy session - at the top of search_process.php
and when this is echoed in search_results.php it works even tho. it has been redirected.
rj
if you mean the dummy session - at the top of search_process.php
Code: Select all
$test = array("2","4","5");
$test = serialize($test);
$_SESSION['tester'] = $test;rj
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
yes i have started the session.
as i said above if i place
at the top of the search_process page - the session will echo on the search_results page but when I move it to just before the redirect, it doesnt echo.
as i said above if i place
Code: Select all
$test = array("2","4","5");
$test = serialize($test);
$_SESSION['tester'] = $test;Not sure if this helps?
php.net
php.net
If you want to use a named session, you must call session_name() before calling session_start()
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am