开发者

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

开发者 https://www.devze.com 2023-03-22 03:00 出处:网络
I have a mobile version web application of my website with domain, main websitehttp开发者_JAVA百科://hello.world.com

I have a mobile version web application of my website with domain, main website http开发者_JAVA百科://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.


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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消