Forum Moderators: coopster

Message Too Old, No Replies

PHP Cookies Problem

         

apacheanderson

8:28 pm on Jun 10, 2003 (gmt 0)

10+ Year Member



I've got a problem setting cookies on my site. I want to set a cookie that last for a year and I've used the line

setcookie( "membercookie", mysql_insert_id(), time() + 31536000);

But the cookie expires when the browser is closed.

Anyone got any idea of what I'm doing wrong?

daisho

9:00 pm on Jun 10, 2003 (gmt 0)

10+ Year Member



Looks good to me. I wonder if the value is overflowing. Try something like time()+86400 and see if that works.

daisho.

apacheanderson

9:24 pm on Jun 10, 2003 (gmt 0)

10+ Year Member



Yeah I've tried setting small expire values but to no avail.

daisho

9:47 pm on Jun 10, 2003 (gmt 0)

10+ Year Member



Is this the first think in your PHP code? Do you get a warning abouit headers already being sent? Just as a quick test add "ob_start();" (no quotes) as the very first line in your PHP block.

daisho.

apacheanderson

10:33 pm on Jun 10, 2003 (gmt 0)

10+ Year Member



The cookie sets fine. It just expires as soon as the browser is closed. I don't get any header errors.

That ob_start() didn't make any difference.

daisho

12:31 am on Jun 11, 2003 (gmt 0)

10+ Year Member



Sorry wan't thinking. The ob_start would have only fixed it if you were getting header errors.

Have you tried different browsers? Or telneted in to see what headers are being sent? Maybe it's a client problem.

daisho