Hi,

In my website i have implemented custom session values. In which, on log on i set the session value to some object. This object is used to extract user specific data from db.

now the problem is If user logs in with : test1.somesite.com and logs off and again logs in with: test2.somesite.com that user is still receiving the data from object specific to test1.somesite.com.

the point is whichever site user frist logs in with the second time if he logs in with anathor subdomain he is always getting the data from previous sub domain login.

on log out from specific domain i cleared all the sessions(tried everything): by putting HttpContext.session["UserDetail"] = null;, HttpContext.Session.Abandon() and also HttpContext.Session.Clear();

but nothing seems to work

and i also don't have much idea how session variables are treated across subdomains.

I mean if i initialize a session with one value by visiting test1.somesite.com will that value also be visible if on the same computer and on same browser i also open test2.somesite.com.

any help please

i found out the solution it was not related something to session. But i also learned something from this problem. For all ASP.NET MVC programmers out there. please notice: if u create a subdomain by url rewriting in asp.net mvc, browser will treat different subdomain as different websites. So browser is going to store a cookie for each subdomain.

For example: if you have www.somesite.com and it's subdomain test1.somesite.com and test2.somesite.com. If u visit each of the above ur, each url will have their own corresponding cookies

and same goes for sessions. different urls different asp.net sessions and cookies.

now about my problem, i used static class to get the url from the address bar, that's what(static class) created the problem. first i visited test1.somesite.com, and retrieved the url using the static class, and from that url i displayed the user data. i don't know but there was something with this static thing, it cached this site address somewhere in memory or server i don't know, if you guys know something about this plesae let me know. Now, after logging out with test1.somesite.com and again logging in with test2.someisite.com, i again called the same function to access the url, but it gave me the url of the site i visited last time, that's the reason why used to get the contents of the site i visited last time than the current one, and everything displayed to the user is always associated with the subdomain.

After removing the static thing and accessing the url using class instance, everything worked well.

Anyways,
thanks to you all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.