nimi
nimi

Reputation: 5507

how to share cookie'es across mobile web application and main web site?

I have a mobile version web application of my website with domain, main website http://hello.world.com mobile website http://m.hello.world.com

if the user logs into my mobile website and user visits main web application he should be logged into the main website as well and viceversa. i am setting login cokkies.

i tried to set the path like:

HttpCookie cookie = FormsAuthentication.GetAuthCookie(userName, isPersistent);
cookie.Path = "/";

but didn't work. Let me know how can i solve this.

Upvotes: 1

Views: 350

Answers (2)

pabdulin
pabdulin

Reputation: 35255

Then you create a cookie it's, by default, is associated with current domain i.e. hello.world.com and m.hello.world.com and retrieved also, by domain. You should look into setting Domain property of a cookie the you create and read them.

Upvotes: 0

Darkwing
Darkwing

Reputation: 7595

You can share cookies across subdomains, by using this technique

ASP.NET Subdomain Cookie (parent and one subdomain)

Effectively you need to add

    cookie.Domain = ".world.com";
    Response.Cookies.Add(cookie)

Upvotes: 1

Related Questions