We help IT Professionals succeed at work.
Get Started

How do I pass session variables from one ASP page to another ASP page?

slegy
slegy asked
on
498 Views
Last Modified: 2015-03-04
After developing extensive procedures to save form variables to session variables in a membership renewal process, I have discovered that Response.Redirect results in the session variables being lost. Well, they are not entirely lost, but I can only save a certain number of them. Based on research, it sounds like none of them should persist through multiple pages, so I am concerned that the results could be random. I found an article (http://weblogs.asp.net/bleroy/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_) that says an overloaded version of Redirect should be used (Response.Redirect("~/default.aspx", false);). Tried that and get:
Microsoft VBScript compilation  error '800a0414'
Cannot use parentheses when calling a Sub
/membership/joinRenew/membershipSession2.asp, line 2266
Response.Redirect("membershipSelect_R2.asp", false)
---------------------------------------------------^

Have also tried Server.Transfer which appears to successfully accomplish the transfer, but I get a different error. The first thing that occurs in the activated page is the opening of a text log file:
<%
Dim conn, rs, sql, alreadyExists, lastName, iTotal
dim whichname, whichdir, whichFN
dim filesys, textfile
dim memText1, memQty1, memAmt1, midx, iidx, temp

whichdir=Server.Mappath ("\membership\joinRenew")
whichname="\coreturn.html"
whichFN=whichdir & whichname
set filesys = Server.CreateObject("Scripting.FileSystemObject")
set textfile = filesys.OpenTextFile(whichFN, 8, 0)%>

textfile.WriteLine "
===============================

<%
Dim item1, quant1, amt1, item2, quant2, amt2, item3, quant3, amt3, item4, quant4, amt4, item5, quant5, amt5, item6, quant6, amt6, item7, quant7, amt7, item8, quant8, amt8, item9, quant9, amt9, item10, quant10, amt10, item11, quant11, amt11, item12, quant12, amt12, item13, quant13, amt13

item1                                = Session("sessitem_name1")
quant1                                = session("sessquantity1")
amt1                                 = session("sessamount1")
textfile.WriteLine Now
textfile.WriteLine "<BR><B>1:   </B>  " & (item1) & "     " & quant1 & "     " & amt1
textfile.WriteLine "<br>===============================<p>"...........................

Microsoft VBScript runtime  error '800a0046'
Permission denied
/membership/joinRenew/membershipSelect_R2.asp, line 13
(Line 13: set textfile = filesys.OpenTextFile(whichFN, 8, 0)%>)

This error doesn't occur when using Response.Redirect???
I've read everything I can find, and have yet to locate a solution. Is there one?
Comment
Watch Question
Developer
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE