Saturday, March 24, 2012

maintaining a single session between http://mysite.com and http://www.mysite.com

Here's what's happening:

I visit my site via http://mysite.com and begin a session. Somewhere
down the road, I might get redirected to another page on my site but
with the www prefix, i.e. http://www.mysite.com/somepage.aspx. Now,
the original session is lost even though I'm viewing the same site.

Is there any way I can maintain a single session in this scenario?
Would this be done on the server (an IIS setting perhaps?) or is this
something I need to manage in code?

Thanks for any help!
-Dustin O'Neilre:

Quote:

Originally Posted by

Is there any way I can maintain a single session in this scenario?


Why should you even bother to maintain a single session in that scenario ?

Just redirect to what you consider your main site from the other site.

A new session will be started in the correct site from that point on.
Just make sure all your links are relative and not absolute.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<dustin.oneil@.gmail.comwrote in message
news:1172164908.663920.175120@.v33g2000cwv.googlegr oups.com...

Quote:

Originally Posted by

Here's what's happening:
>
I visit my site via http://mysite.com and begin a session. Somewhere
down the road, I might get redirected to another page on my site but
with the www prefix, i.e. http://www.mysite.com/somepage.aspx. Now,
the original session is lost even though I'm viewing the same site.
>
Is there any way I can maintain a single session in this scenario?
Would this be done on the server (an IIS setting perhaps?) or is this
something I need to manage in code?
>
Thanks for any help!
-Dustin O'Neil
>


IMO the problem is that it the domain name *appears* to be different. Though
you could perhaps force the domain name for the ASP.NET session cookie
(doesn't seems to be out of the box ? perhaps doing this insite the
application events) my personal preference would be likely to be consistent
(redirect to /somepage.aspx will goes to the same domain you are already in
or you could redirect to mysite.com on the first request to www.mysite.com).

<dustin.oneil@.gmail.coma crit dans le message de news:
1172164908.663920.175120@.v33g2000cwv.googlegroups. com...

Quote:

Originally Posted by

Here's what's happening:
>
I visit my site via http://mysite.com and begin a session. Somewhere
down the road, I might get redirected to another page on my site but
with the www prefix, i.e. http://www.mysite.com/somepage.aspx. Now,
the original session is lost even though I'm viewing the same site.
>
Is there any way I can maintain a single session in this scenario?
Would this be done on the server (an IIS setting perhaps?) or is this
something I need to manage in code?
>
Thanks for any help!
-Dustin O'Neil
>

0 comments:

Post a Comment