Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 20th, 2008, 12:47 AM
Authorized User
 
Join Date: Feb 2006
Location: jaipur, rajasthan, India.
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

Reply With Quote
  #2 (permalink)  
Old November 20th, 2008, 12:52 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #3 (permalink)  
Old November 20th, 2008, 02:07 AM
Authorized User
 
Join Date: Feb 2006
Location: jaipur, rajasthan, India.
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




Reply With Quote
  #4 (permalink)  
Old November 20th, 2008, 03:40 AM
Authorized User
 
Join Date: Feb 2006
Location: jaipur, rajasthan, India.
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>
************************************************** ***************




Reply With Quote
  #5 (permalink)  
Old November 20th, 2008, 09:22 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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
================================================== =========
Reply With Quote
  #6 (permalink)  
Old November 20th, 2008, 09:18 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
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
%>
Reply With Quote
  #7 (permalink)  
Old November 21st, 2008, 12:08 AM
Authorized User
 
Join Date: Feb 2006
Location: jaipur, rajasthan, India.
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
%>

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



Reply With Quote
  #8 (permalink)  
Old November 21st, 2008, 01:22 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
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.
Reply With Quote
  #9 (permalink)  
Old November 21st, 2008, 02:18 AM
Authorized User
 
Join Date: Feb 2006
Location: jaipur, rajasthan, India.
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


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:50 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.