Aaron
Thu Sep 01 11:50:52 CDT 2005
HTTP_REFERER is not always available (see
http://www.aspfaq.com/2169). This
is, however, not one of those cases. This technique worked fine for me, as
long as the click actualy started a new session. I just did this on my own
box, with an HTML file I called from
http://localhost/file.htm, with a link
to
http://my_machine_name/file.asp, where global.asa in the root set a
session variable just like you do below, and file.asp outputs the session
variable. Worked flawlessly, as long as I started from scratch (e.g. closed
the browser).
If you are on your site, and then go to Google, and click on a link that
takes you to your site, session_onstart() won't fire because you still have
the old session.
Don't try to set the string to an empty string in session_onEnd. There is
no point. If session_onEnd is actually being called, then your variables
are blown away for you. But more often than not, it will not be called
(see
http://www.aspfaq.com/2078).
My guess is that session variables are not working
(
http://www.aspfaq.com/2157) or global.asa is not being called at all (see
http://www.aspfaq.com/2076). To isolate the problem, create a global.asa
that sets a session variable (just a constant/string, not based on
servervariables) in session_onstart. Open a new browser window, navigate to
a page that sets a different session variable, then navigate to a third page
that displays them both.
> Then I should able to know the referrer URL. How Do I get that?
>
> I know about Request.ServerVariables("HTTP_REFERER"). So I used this in
> "global.asa" file in "Session_OnStart" event like this:
>
> Sub Session_OnStart
> Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
> End Sub