Page 1 of 1

BASIC COOKIE QUESTION

Posted: Fri May 14, 2010 3:58 pm
by koolsamule
Hi Chaps,

I'm having trouble setting a cookie.

The login.php file is in a directory called 'account'

The cookie name in Termporary Internet Files shows as:
'account/'

instead of the standard
'cookie:user@domain.com'.
This results in the cookie being read by files with the 'account' directory.

I've searched around played around the the $path and $domain variables, but they don't seem to do anything.

Although the PHP code looks like this:

Code: Select all

setcookie($name, $value, $hour); 
The cookie looks like this:
$name, $value, $path, $time
Can someone tell me where I'm going wrong with this?

Re: BASIC COOKIE QUESTION

Posted: Mon May 17, 2010 1:36 pm
by yacahuma
why dont you use sessions?

Re: BASIC COOKIE QUESTION

Posted: Mon May 17, 2010 1:43 pm
by flying_circus
koolsamule wrote: The cookie looks like this:
$name, $value, $path, $time
Your parameter order is wrong.

http://us.php.net/manual/en/function.setcookie.php

The expiry parameter needs to be before the path parameter.

Re: BASIC COOKIE QUESTION

Posted: Wed May 19, 2010 7:24 am
by koolsamule
Hi,

Yeah, I know that, that's why I've coded it like:
setcookie($name, $value, $hour);
Note, I haven't put the $path variable in, however, it appears in the cookie and also the cookie (file) name is 'directory-where-login-script-is/' ????