PDA

View Full Version : Just retrieve the value of a cookie by referencing it's name?


JAB Creations
Fri 10th Jun '05, 4:21am
My cookie's name is "coffee" and it's value is "black".

I want to in as short as possible a way have JS say "black" by SPECIFICALLY referencing the "coffee" cookie.

I figure there is something like ...

document.write (document.cookie[coffee]);

but I'm still learning. I don't want to use g_e_t_c_o_o_k_i_e function or any of that crap. (don't type that as I subtract is from google searchs, others may follow my path eventually).

Anyway does anyone know how to do this? I've searched like an obsessed mad man all night and can't find this! :mad::confused:

daemon
Fri 10th Jun '05, 2:09pm
This (http://www.quirksmode.org/js/cookies.html) is a great site to learn about how JavaScript cookies work. It has an example function of how to read cookies (as it's not as simple as document.cookie[name]) and then explains how the function works.