Re: cookie
| From: | Frank M. Kromann | Date: | Wed, 04 Oct 2000 01:07:55 +0000 |
| Subject: | Re: cookie | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18506@lists.php.net to get a copy of this message | ||
Cookies is a part of the HTTP header and all header information should be sent to the client before
you send any other document information. If you get this error you wont get the cookie set.
You have to move SetCookie() to a position in your code where only header information is send.
- Frank
>I have some pages that require user authentication in order to
>get to the page content. I have done this by switch and case statements
>and MySql. everything was working fine but then I decided to set a cookie
>and use a user_id variable the rest of the site to identify the user. When
>I set the
>cookie with the following code:
>
>//set cookie(if not set)
> if (!isset($user_id)){
> $token = md5(uniqid(rand()));
> setcookie ("user_id", $token, time()+86400, "/",
>".donkey.aloha-street.com");
> }
>
>I get the following error
>
>
>Warning: Cannot add header information - headers already sent by (output
>started at /home/httpd/html/test/members_j.php:8) in
>/home/httpd/html/test/members_j.php on line 130
>
>But the authentication still works.
>Does anyone know what is happening?
>
>thanks in advance
>
>rodney
>
>I am using php4 on linux.
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>