PDA

View Full Version : Help with reading cookies



twQ
12-29-2009, 04:42 AM
Well, I used to be able to. Now I can't. I read the tutorial that taught me the first time and I just can't make it work. Could anyone give a me a refresher on how to READ cookies with JavaScript? Keep it simple if you can haha. Thanks!

jscheuer1
12-29-2009, 04:48 AM
The simple answer is:


alert(document.cookie);

That will give you all of the javascript cookie info for that page. You can parse it any way that you like. Here's my unit (gleaned from the work of many others, then condensed - there are other cookie units out there) that works for most situations:

http://www.dynamicdrive.com/forums/blog.php?b=32

twQ
12-29-2009, 04:50 AM
Thank you for that, and I'll use your code for now but I'm going to try to learn how to do it on my own again I always feel like I'm stealing if I use a script that I don't understand...and since I don't remember how to read cookies I don't understand it haha. Thank you for the script I should be able to figure what I need from it.