You are here: Re: Cookie problem « PHP « IT news, forums, messages
Re: Cookie problem

Posted by Al on 10/04/88 11:37

Al 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.

Problem solved. Was a slap-on-the-forehead, dummy, type.

Note, the test "print_r() BEFORE the setcookie(). It is obviously sent before the html header.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация