[PHP] setcookie problem: Cannot add header information - headers already sent by
here is the example: Feedback form Feedback form ENDH; // End of page header // Saving the page footer in the variable $tail. $tail = << ENDT; // End of page footer // Set up variables that will be saved in the cookies // Define unique cookie prefix $ID = "My_ID"; // Cookie lifetime in seconds (in this example, three days) $cookie_life = 60; // Name of cookie that holds the user's name $n_name = $ID . "_Name"; // Name of cookie that holds the user's email $n_email = $ID . "_Email"; // Name of cookie that holds the user's last login $n_last = $ID . "_Last"; // These lines print the form with user input and mails to the webmaster. if( isset($sfeedback)) { Setcookie($n_last,Date("H:i d/m/Y"),time()+$cookie_life); print $head; ?> Thanks for your feedback, . Here is what you said: Name: Email: Feedback: Welcome to our system! Please fill in the following information: Name: Email: Welcome back to our system, . Name: Email: Feedback: Warning: Cannot add header information - headers already sent by (output started at C:\WebShare\wwwroot\last\cookie.php:59) in C:\WebShare\wwwroot\last\cookie.php on line 75 Warning: Cannot add header information - headers already sent by (output started at C:\WebShare\wwwroot\last\cookie.php:59) in C:\WebShare\wwwroot\last\cookie.php on line 76 Warning: Cannot add header information - headers already sent by (output started at C:\WebShare\wwwroot\last\cookie.php:59) in C:\WebShare\wwwroot\last\cookie.php on line 83 what' wrong? thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] setcookie problem
On Monday 02 July 2001 21:32, scott [gts] wrote: > probably becuase time() is seconds since 1970, and as > far as i understand, once it gets over 999,999,999 > it will not work correctly becuase it will roll over > (similar to the Y2k bug) and become 000,000,000 Typically the limit is 2^31 seconds (a 32Bit signed number) on 32Bit machines (which I assume is used here). So the Y2k equivalent for Unix time() is around mid-2038. -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) ...1000100011010101101010110100111010113... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] setcookie problem
this is my guess at what's happening... i dont know 100% if that's why cookies aren't setting properly, but here's an educated guess on my part: probably becuase time() is seconds since 1970, and as far as i understand, once it gets over 999,999,999 it will not work correctly becuase it will roll over (similar to the Y2k bug) and become 000,000,000 for example: 00,900,000,000 - current time (for example) 36,000,000,000 - what you're trying to add -- 36,900,000,000 - result but the buffer is only big enough for 999,999,999 and so the computer truncates the leading "36" and leaves you with 900,000,000 (which was the exact time that you set the cookie, making it expire as soon as you set it) instead of adding such wildly huge numbers, try adding 1-2 years... besides, it's kind of scary to think that your cookies might outlive you, if that timestamp was really acceptable :) > -Original Message- > From: Mark Lo [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 02, 2001 12:33 PM > To: php general > Subject: [PHP] setcookie problem > > > Hi, > >How to set a forever cookie into client machine. I use the following > syntax to set the cookie, but when I close the brower's window, then the > cookie is deleted when the browser closed. > > setcookie("buyerid",$email,time()+360,"","$domain"); > setcookie("buyeridpasswd",$passwd,time()+360,"","$domain"); > > > Thank you for your attentions, > > > Mark Lo > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] setcookie problem
Hi, How to set a forever cookie into client machine. I use the following syntax to set the cookie, but when I close the brower's window, then the cookie is deleted when the browser closed. setcookie("buyerid",$email,time()+360,"","$domain"); setcookie("buyeridpasswd",$passwd,time()+360,"","$domain"); Thank you for your attentions, Mark Lo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Setcookie problem in ie 5.0
On Fri, 8 Dec 2000, Rustam Nabirov wrote: > I'm using IE5.0 on Win98, it's as simple as it gets. But still I don't see > any cookies saved. As far as I understand, on this platform cookies get > saved in C:\WINDOWS\Cookies, and C:\WINDOWS\Temporary Internet Files has > only shortcuts to those cookies. C:\Windows\Profiles\\Cookies\ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]