Myspace Codes - Power Rangers - Credit Cards - Mortgages - Loans

PDA

View Full Version : Setting Cookies


Dolin
Jan 1st 2008, 4:11 pm
Hi everytime I reload my browser it said my cookie is not set. Is my code wrong?

setcookie('youngcounter', 'dolinred', time() + 36000, '/', '.young.3host.biz');

WeedGrinch
Jan 1st 2008, 7:00 pm
Try this:
setcookie('youngcounter', 'dolinred', time() + 36000, '/', 'young.3host.biz');

I made one simple change.

Dolin
Jan 1st 2008, 8:03 pm
It sitll doesn't work. Cookies are still not set.

if (!isset($_COOKIE['youngcounter']))
{

setcookie('youngcounter', 'dolin', time() + 36000, '/', 'young.3host.biz');

}

Is there anything wrong with the code?

WeedGrinch
Jan 1st 2008, 8:09 pm
setcookie('youngcounter', 'dolin', time() + 36000)

Use that

Dolin
Jan 1st 2008, 8:17 pm
Nope doesn't work still. Is it a problem with my host or my codes? I tried the codes in my localhost and the cookie is set, but I tried it on my website the cookie is not set.

WeedGrinch
Jan 1st 2008, 8:26 pm
I think its your host, because it should work.
BTW you should use sessions!

Ziaja
Jan 1st 2008, 8:32 pm
Before you use cookies, you need ob_start() at the very start of your script.

Dolin
Jan 1st 2008, 11:10 pm
Are you sure Ziaja? My cookies work fine in my local server. I was thinking there is a functional limit at my host. Anyway I am willing to hear about the obj_start() function if it can set up my cookie in my website.

lslars31
Jan 2nd 2008, 1:39 pm
http://www.tizag.com/phpT/phpcookies.php

Try that :)