PDA

View Full Version : Session debug help


MarioPro
08-05-2002, 02:51 AM
Hi,

I've been arround looking for what has been posted and nothing seemed to help me.

Here's the problem...

In my search page "search.php" (where the form is) I have set the session:

session_name("mysession");
session_start();
if(session_is_registered("mysession")){
session_destroy("copy_postvars" );
}

After clicking on submit the user is sent to page "search_details.php" where I have the following code for the session:

session_name("mysession");
session_start();
if(!session_is_registered("mysession_search")){
$mysession_search = "last_search";
session_register( "mysession_search" );
$copy_postvars=$HTTP_POST_VARS;
session_register( "copy_postvars" );
} else {
if(!isset($copy_postvars)) $copy_postvars=$HTTP_POST_VARS;
}

foreach($copy_postvars as $key => $value){
$$key=$value;
}

if($back=='yes'){
if($mysession_lastSearch=="detailed"){
foreach($copy_getvars as $key => $value) $$key=$value;
} else {
$mysession_lastSearch="detailed";
session_register("mysession_lastSearch");
$start_row=0;
$end_row=10;
$copy_getvars["start_row"]=0;
$copy_getvars["end_row"]=10;
session_register("copy_getvars");
exit;
}

} else {
$mysession_lastSearch="detailed";
session_register("mysession_lastSearch");
$copy_getvars=$HTTP_GET_VARS;
session_register("copy_getvars");
}

On this page the user may go to the detail page of each result found on the page "codingtips.php".

Here I only have:

session_start();

I have in this page a link to get BACK to the "search_details.php" page (where the user came from) but when I click there, I do get back to the page but no more with the same results.

Another strange things that is happening, is that when the user clicks the "order by" buttons on the search results page, instead of ordering only on the found results, the query will order on all items on the database. Hummm.. :(

Any help would be apreciated.

Thanks in advance !
;)

gmitra
08-05-2002, 03:17 AM
Not sure if I understand what you are asking, but this may help you on the order by question....

http://www.codingforums.com/showthread.php?s=&threadid=3297

If you don't like the answer on that thread you could try recalling the search query by using $_REQUEST. You have the pass on the search query when you sort the search results otherwise it'll just sort and display everything in the database... I've had this problem for awhile until it was solved today. :)

gmitra

gmitra
08-05-2002, 03:39 AM
Refering back to the other post, $_POST works the first time you try to sort it because it is posting your search query from the other page. After that you use the $_GET statement. Try substituting $_GET for $_REQUEST or follow what was said in the other thread by replacing $_GET with...

<?=$searchparameters?>

and adding this into your script...

<?php

$searchparameters = ( isset($_POST['search']) ) ? $_POST['search'] : $_GET['search'];

?>