ASP Session Variables

V

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
 
A

Anthony Jones

Victor said:
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.
 
M

Mark J. McGinty

Just to clarify a bit...

Anthony Jones said:
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
 
V

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.
 
M

Mark J. McGinty

Victor said:
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
 
G

google

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top