Help! browser refreshes twice with setcookie.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mq
Forum Newbie
Posts: 2
Joined: Sun Jul 18, 2004 8:30 am

Help! browser refreshes twice with setcookie.

Post by mq »

I have a problem with my php code. It seems that it's making my browser referesh twice some times. That is, when I referesh the page it loads the contents, and then it reloads it again.

This happened after I added code handling another cookie (setting it). When I comment out the setcookie statment it does not reload again.

Anyone had this problem before?

Thanks.

MQ
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

PHP Manual Setcookie wrote: Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires.
Might be because you are verifying the $_COOKIE in an odd way? Please do provide more info, parts of code or similiar.


feyd | fixed [/quote] ;)
mq
Forum Newbie
Posts: 2
Joined: Sun Jul 18, 2004 8:30 am

Post by mq »

It turned out that setcookie with an empty string then setting it again with some value was the problem. I removed the setcookie("mycookie", "") and it's working fine now.

Still the question holds, did anyone face this before?
Post Reply