ASP Session Variables

ASP Session Variables

am 23.01.2007 00:35:59 von Victor

I've got a website that displays the same whether it is accessed using www. or not.

ex: http://www.mysite.com and http://mysite.com give me exactly the same website (both
represent the top subdomain).

HOWEVER... it seems that while they share the same application variables (of course)
they treat session variables as if they are two different websites. (this is very
important because when a user clicks a link that switches from one to the other, it
affects some counters).

Is there a way to insure that both ways of entering the URL will share the same set of
session variables???

Thanks,

Victor

Re: ASP Session Variables

am 23.01.2007 09:55:32 von Anthony Jones

"Victor" wrote in message
news:OGeSQ4nPHHA.1756@TK2MSFTNGP05.phx.gbl...
> I've got a website that displays the same whether it is accessed using
www. or not.
>
> ex: http://www.mysite.com and http://mysite.com give me exactly the same
website (both
> represent the top subdomain).
>
> HOWEVER... it seems that while they share the same application variables
(of course)
> they treat session variables as if they are two different websites. (this
is very
> important because when a user clicks a link that switches from one to the
other, it
> affects some counters).
>
> Is there a way to insure that both ways of entering the URL will share the
same set of
> session variables???
>

You need to configure a new site. Place a host header entry on the new site
for mysite.com. This new site should be empty except for a custom 404
handler which redirects to the www.mysite.com site. Ensure the original
site has a host header (if any) only for www.mysite.com.

There is no way for the two different URL to share session variables. ASP
sessions depend on a in-memory cookie where the URL to the root of the
application is the path. Since this will vary between with the two names
they cannot share this cookie.

Re: ASP Session Variables

am 25.01.2007 14:15:53 von mmcginty

Just to clarify a bit...

"Anthony Jones" wrote in message
news:uTKu%23wsPHHA.320@TK2MSFTNGP06.phx.gbl...
>
> "Victor" wrote in message
> news:OGeSQ4nPHHA.1756@TK2MSFTNGP05.phx.gbl...
>> I've got a website that displays the same whether it is accessed using
> www. or not.
>>
>> ex: http://www.mysite.com and http://mysite.com give me exactly the same
> website (both
>> represent the top subdomain).
>>
>> HOWEVER... it seems that while they share the same application variables
> (of course)
>> they treat session variables as if they are two different websites. (this
> is very
>> important because when a user clicks a link that switches from one to the
> other, it
>> affects some counters).
>>
>> Is there a way to insure that both ways of entering the URL will share
>> the
> same set of
>> session variables???
>>
>
> You need to configure a new site. Place a host header entry on the new
> site
> for mysite.com. This new site should be empty except for a custom 404
> handler which redirects to the www.mysite.com site.

And in that 404 handler be sure to relay any QueryString parameter/value
pairs to the target, and be certain that none of your pages' internal links
point to the redirecting domain, and be *absolutely* certain that none of
your pages' code redirects to the redirecting domain.


> Ensure the original
> site has a host header (if any) only for www.mysite.com.

They must both have host headers if both names resolve to the same IP.
Further, neither host name can be duplicated in multiple virtual server
definitions [using the same IP] without causing a bindings conflict.


-Mark


> There is no way for the two different URL to share session variables. ASP
> sessions depend on a in-memory cookie where the URL to the root of the
> application is the path. Since this will vary between with the two names
> they cannot share this cookie.
>
>
>
>

Re: ASP Session Variables

am 29.01.2007 19:07:02 von Victor

Thanks, I understand what both of you are writing.

However... www.mysite.com and mysite.com, by definition and standard, point to the same
website with the same IP address - that is, the top level subdomain.

Of course, www2.mysite.com and www.mysite.com can be different websites with different
IP addresses.

Re: ASP Session Variables

am 29.01.2007 21:06:15 von mmcginty

"Victor" wrote in message
news:OXp4EB9QHHA.4632@TK2MSFTNGP04.phx.gbl...
> Thanks, I understand what both of you are writing.
>
> However... www.mysite.com and mysite.com, by definition and standard,
> point to the same
> website with the same IP address - that is, the top level subdomain.

Not by any standard I've seen, and absolutely not by definition. mysite.com
and www.mysite.com are 2 separate host names, how they resolve is
*entirely* up to DNS. If you had said 'by convention', I'd have to agree,
but that's the extent of it.

> Of course, www2.mysite.com and www.mysite.com can be different websites
> with different
> IP addresses.

www2 and www are neither no more nor no less related to their parent domain.
www is merely a very widely used convention, nothing more. It could just
as easily be xxx. or xyz., the letters themselves mean nothing to DNS, they
have no special significance.

Note that if you were talking about regular cookies (as opposed to the
session cookie) you could use the domain property to allow child domains to
reference cookies in the parent domain, but you have no control over the
session cookie at all, it's a black box. So if you need to support multiple
host names for the same logical site, *and* the ASP session, redirection is
your solution.


-Mark

Re: ASP Session Variables

am 01.02.2007 15:41:26 von google

On 22 Jan, 23:35, "Victor" wrote:
> I've got a website that displays the same whether it is accessed using www. or not.
>
> ex:http://www.mysite.com andhttp://mysite.comgive me exactly the same website (both
> represent the top subdomain).
>
> HOWEVER... it seems that while they share the same application variables (of course)
> they treat session variables as if they are two different websites. (this is very
> important because when a user clicks a link that switches from one to the other, it
> affects some counters).
>
> Is there a way to insure that both ways of entering the URL will share the same set of
> session variables???
>
> Thanks,
>
> Victor

what i would do is have an if statement at the top of the page that
sais that if header is http://mysite.com then redirect to http://www.mysite.com
end if

Re: ASP Session Variables

am 01.02.2007 17:12:56 von Anthony Jones

wrote in message
news:1170340886.251595.316130@v45g2000cwv.googlegroups.com.. .
> On 22 Jan, 23:35, "Victor" wrote:
> > I've got a website that displays the same whether it is accessed using
www. or not.
> >
> > ex:http://www.mysite.com andhttp://mysite.comgive me exactly the same
website (both
> > represent the top subdomain).
> >
> > HOWEVER... it seems that while they share the same application variables
(of course)
> > they treat session variables as if they are two different websites.
(this is very
> > important because when a user clicks a link that switches from one to
the other, it
> > affects some counters).
> >
> > Is there a way to insure that both ways of entering the URL will share
the same set of
> > session variables???
> >
> > Thanks,
> >
> > Victor
>
> what i would do is have an if statement at the top of the page that
> sais that if header is http://mysite.com then redirect to
http://www.mysite.com
> end if
>

Which page?