Re: Cookie problem

From: Date: Sat, 14 Jan 2006 22:57:05 +0000
Subject: Re: Cookie problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-228622@lists.php.net to get a copy of this message
Try simplifying the problem to determine the error point. For example don't involve $_POST just try setting a cookie with hard coded variables. If that works then add in the $_POST and test for BOTH $_POST['prefs'] and $_POST['filter']. Example of simplification: <?php // Send cookie setcookie("listpref","selected",time()+7776000); ?> Aaron On 1/14/06, Al <news@ridersite.org> wrote: > > Can't get a cookie to set. Below is the code near the file top BEFORE any > html output. > > $_POST['prefs'] comes from a hidden field in the middle of the html > output. > > $_POST['filter'] comes from a select option. > > A Submit button closes the page and refreshes it. > > print_r($_POST) shows $_POST['prefs'] $_POST['prefs'] are just as I expect > when the page refreshes. > > ## code > print_r($_POST) > session_start(); > print_r($_COOKIE); > > if(isset($_POST['prefs'])) > $cookie= setcookie("listpref", $_POST['filter'], time()+7776000); > > var_dump($cookie) shows bool TRUE > > I added the session_start() as a test. > > print_r($_COOKIE) shows the session ID cookie works just fine. > > IE6 and Firefox don't record the regular cookie. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#228622) next »