Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    Mobile, AL
    Posts
    138

    Session Dropping

    I have a search form that goes to search.php?page=1 (has pagination). At the top of search.php I have:

    PHP Code:
    <?
    session_start
    ();
    $_SESSION['keyword'] = $_POST["keyword"];
    ?>
    Further in my code I explode $_SESSION['keyword'] (to alter the terms for boolean search), implode the terms and pass them off to my MySQL query. This all works, it returns the first page of results. Yet when I click the next page (search.php?page=2) it returns nothing, the session variable no longer exists.

    Any ideas as to why this is happening? I'm not super great with sessions, but something simple like this should work.
    Shawn Kerr

  2. #2
    Join Date
    Jan 2004
    Location
    Mobile, AL
    Posts
    138
    Well, I figured out I was going about it the wrong way anyway. I was trying to recapture what I had already posted and altered for the boolean search. So had it worked, I would have resubmitted the boolean search to be altered for boolean search another time.

    But I realized just a few minutes ago that once the script terminates I lose my keywords altogether.

    PHP Code:
    $keys explode(" "$_POST['keyword']); //back to original code w/o sessions
       
    foreach ($keys as $newkey) {
    $var[] = "+$newkey";
    }
    $newkeys implode(" "$var);

    // $newkeys is now +keyword1 +keyword2 etc.

    // mysql [fulltext] query with $newkeys works

    // print results just fine

    echo $newkeys// empty, well actually just + 
    So I need to figure out how to keep $newkeys alive period, but through the pagination.
    Shawn Kerr

  3. #3
    Join Date
    Jan 2004
    Location
    Mobile, AL
    Posts
    138
    Oh well. I just passed everything through the URL. 2 minutes. No headaches.
    Shawn Kerr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •