Javascript cookies

I have cookies for domain .forum.mywebsite.com

and for .mywebsite.com

.

Is it possible to read a cookie for a domain .mywebsite.com

with javascript from a location forum.mywebsite.com

?

+2


source to share


3 answers


Yes, you should read this. Check out the following articles.

When the JavaScript preset is set, the process is called, the script either represents the browser with a domain or empty. If the domain is not specified it is assumed to be the scope of the ie java-programming.suite101.com page in this case.

The JavaScript cookie path on the other hand allows the programmer to verify that the cookie is valid (sent to the server) for pages in a specific path on the website. For example, defining a path like / blog will restrict the cookie to my.domain.com/blog. If the cookie is to be applied as a whole (sub) then the path = / must be specified.



But you will not be able to delete the cookie from the subdomain. Check out this question on SO: Is it possible to delete subdomain cookies?

+3


source


You can set the domain that has access to a given cookie by adding a value for the cookie attribute

domain={domainname};

      



If {domainname} starts with a presenter .

, any subdomain can also access the cookie (source: MDC ).

As per RFC 2965 referenced by the W3C spec , a presenter is .

not needed, but better secure than sorry;)

+1


source


the cookie is sent to the server as part of the request, this is not something that is available from the client as far as I know (therefore not available for javascript).

-3


source







All Articles