1

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.

nimi
  • 5,359
  • 16
  • 58
  • 90

2 Answers2

1

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)
Community
  • 1
  • 1
Matt Evans
  • 7,113
  • 7
  • 32
  • 64
  • I have changed the host file of developing machine to m.local.hello.my and local.hello.my for testing purpose and setting the cookie.Domain = ".hello.my"; Is there any mistake, doing something like this. this is not working. – nimi Jul 20 '11 at 10:34
  • Haven't tested myself, but should work. Have you cleared all your cookies for all .hello.my domains to start with? – Matt Evans Jul 20 '11 at 12:37
  • yeah i have cleared all the cookies. but the fact is that i am not able to logout, its not clearing that cookies. – nimi Jul 21 '11 at 05:08
  • i got solution from this http://www.codeproject.com/KB/aspnet/SingleSignon.aspx?display=Mobile – nimi Jul 28 '11 at 06:03
  • Ah, I assumed your subdomain was hosted on the same server. The machinekey stuff should be unnecessary if that was the case – Matt Evans Jul 29 '11 at 03:52
0

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.

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96