Save and read a site-wide cookie

M

Mark1234567

I wonder if you can help me with the following:

What is the Javascript code to store a site-wide cookie? (I want to
record whether a person has been to my site before).

What would be the code to read this value?

TIA
Mark
 
M

Mark1234567

Thanks for the reply but I think you misunderstood my question.

The code you gave states "The next time the visitor arrives at the
*same page*, he or she will get welcome message."

I want the cookie to be able to be read/written for other pages in the
website as well.

TIA
Mark
 
B

Bart Van der Donck

Mark1234567 said:
The code you gave states "The next time the visitor arrives at the
*same page*, he or she will get welcome message."

I want the cookie to be able to be read/written for other pages in the
website as well.

That should be no problem. All web pages of the same domain have read/
write access to the cookie.
 
T

Thomas 'PointedEars' Lahn

Mark1234567 said:
What is the Javascript code to store a site-wide cookie? (I want to
record whether a person has been to my site before).

What would be the code to read this value?

That depends on what you call a site. For a document resource with the same
second-level domain, subdomain or path you have to set the `domain' or
`path' parameters appropriately as defined in the Cookie specification.

Avoid W3Schools when looking for reliable reference material. In this case,
use the references pointed to by

http://en.wikipedia.org/wiki/HTTP_cookie

and vendor's documentation, for example

http://developer.mozilla.org/en/docs/DOM:document.cookie

instead.


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,373
Latest member
Desiree036

Latest Threads

Top