Forum Moderators: coopster

Message Too Old, No Replies

Cookie question

For reading the cookie

         

ashish2005

7:24 pm on Sep 14, 2009 (gmt 0)

10+ Year Member



Ok I have been trying to use php cookie on my website.

I set the cookie with random names like this.

$r=rand();
setcookie("rand_".$r, $r, time()+(60*60*24), "/");

Then in some other page $r is unknown. Then can I find out what cookies have been set by my website in order to get the names of the cookies or the $r.

Thanks

PokeTech

7:48 pm on Sep 14, 2009 (gmt 0)

10+ Year Member



Well if you want to see all your cookies on your website you can use: print_r($_COOKIE); that will display all of them.

If you named your cookie rand_ you can use: echo $_COOKIE['rand_'];

Hope that is what your looking for.

omoutop

12:50 pm on Sep 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ashish2005, the only way to know what cookie you have set with your code, is to have your $r stored somewhere

If you have set multiple cookies, then follow PokeTech's advice and use print_r($_COOKIE);. This will get you all cookies and you can easily find your various $r from their names