Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 20th, 2008, 12:47 AM
Authorized User
 
Join Date: Feb 2006
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur
Default session variable lost after redirec in classic ASP

Hi,

i am facing some problem regarding redirection and session variables

after setting session variable, if i redirect the page, all session variables are lost.

tried to find solution over internet but most of the solution are for asp.net, i could not found any solution for classic asp.

if anyone has any idea how to overcome the problem, will be great help.

contact.asp?contactMode= enquiryForm
************************************************** *********
   session("enqName") = request.form("enqWebname")

   Dim RedirectUrl
   RedirectUrl = "contactus.asp?status=success"
   Response.Redirect(RedirectUrl)

************************************************** *********

contact.asp?status=success
************************************************** *********
  dim Name
  Name = session("enqName")

   Response.write(Name)
************************************************** *********



thanks for spending time to reading this problem

all suggestions are welcome

thanks and regards
ashok sharma

 
Old November 20th, 2008, 12:52 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Are you sure request.form("enqWebname") contains a value?

Session variables arnt that complex. They certainly do not fail when redirecting.

Just before:

session("enqName") = request.form("enqWebname")

write request.form("enqWebname") to the browser to check it has a value

Wind is your friend
Matt
www.elitemarquees.com.au
 
Old November 20th, 2008, 02:07 AM
Authorized User
 
Join Date: Feb 2006
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur
Default

hi, thanks for reply

i have checked, when i disable that redirection code... session variable gives the values, and after enabling it gives nothing

thanks again

if you require, i will post full code

thanks again

ashok sharma




 
Old November 20th, 2008, 03:40 AM
Authorized User
 
Join Date: Feb 2006
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur
Default

calling page
************************************************** ***********
<%
if (CStr(Request("check")) = "redirect") Then
  response.Write("enterred into check")
    if Request.Form("name") <> "" then
       response.Write(" value : " & CSTR(Request.Form("Name")))

       Session("Name") = Request.Form("name")

       Response.Write(session("Name"))
       'Response.Redirect("untitled3.asp") %>

       <a href="untitled3.asp">link</a>
       <%
       else
       Response.Write("No Value")
       end if
else
    Response.Write("not entered into redirect")

end if
%>


<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<form action="untitled-21.asp" method="post" name="ashok">
<input name="name" type="text" size="25" />
<input name="check" type="hidden" value="redirect" />
<input name="ok" type="submit" />
</form>
</body>
</html>

************************************************** ******************

redirected Page
************************************************** ******************
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
   <%
        dim naam
    if naam <> "" then
       naam = session("Name")
       response.Write(naam)
    else
       Response.Write("No Session Value")
    end if
%>

</body>
</html>
************************************************** ***************




 
Old November 20th, 2008, 09:22 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This logic is wrong:
Code:
   <%
    dim naam
    if naam <> "" then
       naam = session("Name")
       response.Write(naam)
    else
       Response.Write("No Session Value")
    end if
%>
Specifically, these 2 lines:

Code:
    dim naam
    if naam <> "" then
Your if statement is always going to evaluate as false because you declare naam without first assigning a value to it so naam is always going to equal an empty string.

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old November 20th, 2008, 09:18 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

In other words, Doug is telling you to swap two lines of your code, thus:
Code:
<%
    dim naam
    naam = session("Name")
    if naam <> "" then
       response.Write(naam)
    else
       Response.Write("No Session Value")
    end if
%>
 
Old November 21st, 2008, 12:08 AM
Authorized User
 
Join Date: Feb 2006
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur
Default

sorry that was typing mistake here only.

in my code it is
**********
<% dim naam
    naam = session("Name")
    if naam <> "" then
        response.Write(naam)
    else
        Response.Write("No Session Value")
    end if
%>

******************************



 
Old November 21st, 2008, 01:22 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I guess I have to ask the obvious question: Do you have cookies disabled???

If you disable cookies, session variables do *NOT* work.
 
Old November 21st, 2008, 02:18 AM
Authorized User
 
Join Date: Feb 2006
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur
Default

hi

what i found that my code is working if i upload it to web server,
not working at my pc,

i have checked that:
server variables get initiated and value exists till i am on the same page

both server variables and request.form shows the value on same page
and cookies are enabled.

is this firewall problem. i am having zonealarm firewall

regards







Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP5 session variable lost totti Pro PHP 3 April 3rd, 2009 11:16 PM
How to assign a new value to Classic ASP variable mcinar Javascript How-To 4 April 14th, 2008 06:02 PM
kill Classic ASP session when clicking browser 'X' crmpicco Javascript How-To 2 February 2nd, 2006 10:22 AM
How are Session variable maintened in ASP rekha_jsr Classic ASP Basics 1 November 30th, 2004 07:29 AM
ASP session variable problem asifqua Classic ASP Databases 4 June 5th, 2003 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.