Can I get cookies from other than the current path?

U

UncleStoner

Using Javascript, you can call document.cookie to get a list of all the
cookies that will be sent to the path of the current document. Is
their a way to get all the cookies associated with the current domain
without regard to the path of the current document?

For example, if there is a cookie with path=/foo and a cookie with
path=/bar, and I have javascript in the page /foo/cool.html: Can I
query the cookie with the path of /bar as well as the cookie with the
bath of /foo? By default, document.cookie only returns the cookies
that would be sent with an HTTP request to /foo.

Thanks,
Dave
 
M

Michael Winter

Using Javascript, you can call document.cookie

Correction: you can read the property. It isn't a function.
Is their a way to get all the cookies associated with the current domain
without regard to the path of the current document?

No. That would be a security violation. Consider service providers and
hosts that assign users subdirectories not (sub-)domains. However, you
can assign a directory when setting the cookie (using the path
parameter) that is common to both documents.

Mike
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top