For Programmers: Free Programming Magazines  


Home > Archive > ASP > October 2006 > How to Write into a Cross-Subdomain Cookie









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to Write into a Cross-Subdomain Cookie
flip79

2006-10-30, 6:59 pm

Hello and sorry for my english, I'm italian...

I manage a site with a normal address like: www.mysite.com
I'm using a cookie to store nicks of my users, with a code like this:
----
Response.Cookies("mycookie").Expires = #January 1, 2030#
Response.Cookies("mycookie").Path = ""
Response.Cookies("mycookie").Secure = FALSE
Response.Cookies("mycookie")("nick") = nick
----

and I'm deleting it, if a user wants so, with:
----
Response.Cookies("mycookie").Expires = #January 1, 2003#
Response.Cookies("mycookie").Path = ""
Response.Cookies("mycookie").Secure = FALSE
Response.Cookies("mycookie")("nick") = ""
Response.Cookies("mycookie") = ""
----
(I know, there's too much stuff in the delete procedure!)

Now I'm going to open some new sections of my site, with subdomain
adresses, like search.mysite.com, shop.mysite.com... and I need that
cookie authentication for the main (www) address is working also in
these subdomains.

I red on the Internet that with the DOMAIN property, I can set my
cookie to make it work for every subdomain, with something like:
----
Response.cookies("mycookie").domain = ".mysite.com"
----

.... and it works!
My problem is when I try to DELETE it: after I set a cookie with
..domain property, it seems to become "read only": any my attempt to
delete (or modify) it seems to be ignored.

Results are the same when I try to write it from the subdomain that
created it (www), or when I try from the "chief" address (mysite.com,
without any subdomain).

Where's my mistake?

Thanks everybody in advance.

flip79

2006-10-30, 6:59 pm

flip79 wrote:

> Hello and sorry for my english, I'm italian...
>
> I manage a site with a normal address like: www.mysite.com
> I'm using a cookie to store nicks of my users, with a code like this:
> ----
> Response.Cookies("mycookie").Expires = #January 1, 2030#
> Response.Cookies("mycookie").Path = ""
> Response.Cookies("mycookie").Secure = FALSE
> Response.Cookies("mycookie")("nick") = nick
> ----
>
> and I'm deleting it, if a user wants so, with:
> ----
> Response.Cookies("mycookie").Expires = #January 1, 2003#
> Response.Cookies("mycookie").Path = ""
> Response.Cookies("mycookie").Secure = FALSE
> Response.Cookies("mycookie")("nick") = ""
> Response.Cookies("mycookie") = ""
> ----
> (I know, there's too much stuff in the delete procedure!)
>
> Now I'm going to open some new sections of my site, with subdomain
> adresses, like search.mysite.com, shop.mysite.com... and I need that
> cookie authentication for the main (www) address is working also in
> these subdomains.
>
> I red on the Internet that with the DOMAIN property, I can set my
> cookie to make it work for every subdomain, with something like:
> ----
> Response.cookies("mycookie").domain = ".mysite.com"
> ----
>
> ... and it works!
> My problem is when I try to DELETE it: after I set a cookie with
> .domain property, it seems to become "read only": any my attempt to
> delete (or modify) it seems to be ignored.
>
> Results are the same when I try to write it from the subdomain that
> created it (www), or when I try from the "chief" address (mysite.com,
> without any subdomain).
>
> Where's my mistake?
>
> Thanks everybody in advance.


Can't nobody answer? Please help me, I'm still on this problem :(

Anthony Jones

2006-10-30, 6:59 pm


"flip79" <flip79@gmail.com> wrote in message
news:1161740890.227303.239210@h48g2000cwc.googlegroups.com...
> Hello and sorry for my english, I'm italian...
>
> I manage a site with a normal address like: www.mysite.com
> I'm using a cookie to store nicks of my users, with a code like this:
> ----
> Response.Cookies("mycookie").Expires = #January 1, 2030#
> Response.Cookies("mycookie").Path = ""
> Response.Cookies("mycookie").Secure = FALSE
> Response.Cookies("mycookie")("nick") = nick
> ----
>
> and I'm deleting it, if a user wants so, with:
> ----
> Response.Cookies("mycookie").Expires = #January 1, 2003#
> Response.Cookies("mycookie").Path = ""
> Response.Cookies("mycookie").Secure = FALSE
> Response.Cookies("mycookie")("nick") = ""
> Response.Cookies("mycookie") = ""
> ----
> (I know, there's too much stuff in the delete procedure!)
>
> Now I'm going to open some new sections of my site, with subdomain
> adresses, like search.mysite.com, shop.mysite.com... and I need that
> cookie authentication for the main (www) address is working also in
> these subdomains.
>
> I red on the Internet that with the DOMAIN property, I can set my
> cookie to make it work for every subdomain, with something like:
> ----
> Response.cookies("mycookie").domain = ".mysite.com"
> ----
>
> ... and it works!
> My problem is when I try to DELETE it: after I set a cookie with
> .domain property, it seems to become "read only": any my attempt to
> delete (or modify) it seems to be ignored.
>
> Results are the same when I try to write it from the subdomain that
> created it (www), or when I try from the "chief" address (mysite.com,
> without any subdomain).
>
> Where's my mistake?
>


Exact code you are using to create the cookie and exact code you are using
to delete it would help.

My guess is that you aren't using .domain = ".mysite.com" when deleting it.


> Thanks everybody in advance.
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com