I'm having a problem with cookies over several pages. I've tried to set 
them up per the manual, ie: prior to header, and using 
setcookie('cookiename',$value,time()+3600). The cookie seems to be 
created fine on the first page, and passed to the second page, but is 
not maintained when the pages are re-viewed.

I am trying to use this to assign a user id when someone comes in, and 
keep their id while they go through various searches and resulting 
pages, as well as keeping their search parameters for them. But when 
they go to a new search, all the data gets wiped and it starts all over.

I have the cookie set for an hour, but it is empty when the search is 
run again. I thought cookies would remain in effect for the duration of 
the life (an hour) and be accessible to the pages over again.

Help??

My code is as follows:

search.php:
        if (!isset($user_data)) {
                setcookie("user_data","",time()+(3600));        // set for 6 weeks 
*24*7*6
        }
                [snip]
        if($user_data=="") {    
                $sql="insert into user (last_login) values (now())";
                mysql_query($sql);
                $myID= mysql_insert_id();
                $user_data = $myID;
        }

search_result.php:
        if (isset($user_data)) { $myID = $user_data; }


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to