ASP Classic Session Variable Not Always Getting Set
Posted
by Mike at KBS
on Stack Overflow
See other posts from Stack Overflow
or by Mike at KBS
Published on 2010-04-14T15:52:36Z
Indexed on
2010/04/14
17:43 UTC
Read the original article
Hit count: 805
asp-classic
I have a classic ASP site I'm maintaining and recently we wanted to do special rendering actions if the visitor was coming from one specific set of websites. So in the page where those visitors have to come through to get to our site, I put a simple line setting a session variable:
<!-- #include virtual="/clsdbAccess.cs"-->
<%
set db = new dbAccess
%>
<html>
<head>
...
<script language="javascript" type="text/javascript">
...
</script>
</head>
<body>
<%
Session("CAME_FROM_NEWSPAPER") = "your local newspaper"
...
%>
... html stuff ...
</body>
</html>
Then, in all the following pages, whenever I need to put up nav links, menus, etc., that we don't want to show to those visitors, I test for if that session variable is "" or not, then render accordingly.
My problem is that it seems to work great for me in development, then I get it out into Production and it works great sometimes, and other times it doesn't work at all. Sometimes the session variable gets set, sometimes it doesn't. Everything else works great. But our client is seeing inconsistent results on pages rendered to their visitors and this is a problem. I've tried logging on from different PC's and I confirm that I get different, and unpredictable, results. The problem is I can't reproduce it at will, and I can't troubleshoot/trace Production.
For now I've solved this by just creating duplicate pages with the special rendering, and making sure those visitors go there. But this is a hack and will eventually be difficult to maintain.
Is there something special or inconsistent about session variables in Classic ASP? Is there a better way to approach the problem? TIA.
© Stack Overflow or respective owner