Page 1 of 1

cookie reading

Posted: Fri Oct 16, 2009 6:29 am
by itsmani1
Hi

I wanted to see if cookie is set or not...

For example i have site example.com and there is directory named member in it

i set a cookie in that directory i.e. example.com/cookie

can i read and/or access that cookie value from example.com ?

if i can please tell me how...

my domain name:
example.com
i set a cookie at:
example.com/member

and now i wanted to read it from example.com

Re: cookie reading

Posted: Fri Oct 16, 2009 7:20 am
by superdezign
Cookies are domain-specific. Any cookie made on example.com at any directory will belong to example.com. In PHP, you can access your domain's cookie by using the $_COOKIE superglobal array.

Re: cookie reading

Posted: Fri Oct 16, 2009 7:57 am
by itsmani1
you mean like :

Code: Select all

print($_COOKIE);

Re: cookie reading

Posted: Fri Oct 16, 2009 8:05 am
by itsmani1
currently i am at example.com/members

I set a cookie "test_cookie"

I can access it here but i wanted to access it when i go back to example.com

I tired it this way:

Code: Select all

<?PHP
print_r($_COOKIE);
?>
but it's not showing my anything

but when i go to example.com/members and use same code i get value

Re: cookie reading

Posted: Fri Oct 16, 2009 11:00 am
by superdezign
Are you sure that you are creating the cookie correctly? You haven't shown the code that you use to set your cookie.

http://php.net/cookies