Page 1 of 1

cookie does not get saved

Posted: Fri May 23, 2008 5:23 am
by thosecars82
hello there
I am creating a cookie with php which actually does exist because I can check it in the opera browser for example:tools-preferences-advanced-cookies-manage cookies. The cookie does not get saved for next time I open the browser though. Do you know how to fix this?
The example is for a cookie which remembers the language in http://www.metatradersoftware.com. May be you can check with your browsers what I mean.
Thanks in advance

Re: cookie does not get saved

Posted: Fri May 23, 2008 5:48 am
by panic!
you need to set a time limit on the cookie.

Code: Select all

setcookie('yourname','steve',time()+3600);
will expire after an hour.

Code: Select all

setcookie('yourname','steve',time()+86400);
will expire after a day

Re: cookie does not get saved

Posted: Fri May 23, 2008 5:54 am
by thosecars82
panic! wrote:you need to set a time limit on the cookie.

Code: Select all

setcookie('yourname','steve',time()+3600);
will expire after an hour.

Code: Select all

setcookie('yourname','steve',time()+86400);
will expire after a day
Thks for that effective reply.

Re: cookie does not get saved

Posted: Fri May 23, 2008 6:03 am
by thosecars82
thosecars82 wrote:
panic! wrote:you need to set a time limit on the cookie.

Code: Select all

setcookie('yourname','steve',time()+3600);
will expire after an hour.

Code: Select all

setcookie('yourname','steve',time()+86400);
will expire after a day
Thks for that effective reply.
Guess what's the problem now?
I get this message:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pruebalocal1\metatradersoftwarecaca\anexos\header.php:8) in C:\xampp\htdocs\pruebalocal1\metatradersoftwarecaca\anexos\header.php on line 159
Does anybody know how to avoid that the setcookie function throw this warning?
Thanks in advance

Re: cookie does not get saved

Posted: Fri May 23, 2008 6:31 am
by thosecars82
thosecars82 wrote:
thosecars82 wrote:
panic! wrote:you need to set a time limit on the cookie.

Code: Select all

setcookie('yourname','steve',time()+3600);
will expire after an hour.

Code: Select all

setcookie('yourname','steve',time()+86400);
will expire after a day
Thks for that effective reply.
Guess what's the problem now?
I get this message:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pruebalocal1\metatradersoftwarecaca\anexos\header.php:8) in C:\xampp\htdocs\pruebalocal1\metatradersoftwarecaca\anexos\header.php on line 159
Does anybody know how to avoid that the setcookie function throw this warning?
Thanks in advance
solved

Re: cookie does not get saved

Posted: Fri May 23, 2008 6:53 am
by panic!
glad to be of service.