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
cookie reading
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: cookie reading
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.
- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
Re: cookie reading
you mean like :
Code: Select all
print($_COOKIE);- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
Re: cookie reading
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:
but it's not showing my anything
but when i go to example.com/members and use same code i get value
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 when i go to example.com/members and use same code i get value
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: cookie reading
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
http://php.net/cookies