Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Share cookie values across sub domains

Hi Experts -

I have three sites that are all on the same domain, but with different sub domains.

main.mydomain.com
subone.mydomain.com
subtwo.mydomain.com

Within the main.mydomain.com I create a cookie...

Dim aCookie As New HttpCookie("userInfo")
        aCookie.Values("UserID") = UserID
        aCookie.Values("FirstName") = First
        aCookie.Values("LastName") = Last
        aCookie.Values("Rights") = Rights
        aCookie.Expires = DateTime.Now.AddDays(1)

Open in new window


I want to be able to access these cookie values from the other two sub domains?  Is there a way for me to modify the code I used to create the cookie OR the code below so I can access these values across sub domains?

Label1.Text = Server.HtmlEncode(Request.Cookies("userInfo")("UserID")) 

Open in new window


Thanks
0
cdemott33
Asked:
cdemott33
  • 2
  • 2
1 Solution
 
GaryCommented:
Set the cookie without a sub domain.
0
 
cdemott33Author Commented:
Can you provide an example on how to do that?
0
 
GaryCommented:
Response.Cookies("CookieName").Domain = "yourdomain.com"
0
 
cdemott33Author Commented:
Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now