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 Components
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 16th, 2006, 09:07 AM
Registered User
 
Join Date: Jan 2006
Location: Athens, Attiki, Greece.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP SESSION CONTENTS VARIABLES CAN'T BE CHANGED

Hello everyone,
 I would appreciate your help on the following situation:
In the global.asa a session content variable “Colored” is set to 0. In two asp scripts, the first is changing the session(“Colored”) variable to 1 (from 0) and the second (depending the value of the variable) is just responding a simple message. However, the value remains the same (the old one - 0) when the new script is running
(the following scr2.asp is writing “you choose not to ….” And the session(“colored”) is Zero )

Global.asa:

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_onStart
    Session("Colored") = 0
end Sub
</SCRIPT>

--------------------

Scr1.asp:
<%
    Session(“Colored”) = 1
    Response.redirect “scr2.asp”

%>
-------------------
Scr2.asp
<%
    If Session(“Colored”) = 0 then
        Response.write “You choose not to display colors” & “<br>”
    Else
        Response.write “Ok! Colors accepted” & “<br>”
    End if
    Response.write Session(“Colored”)
%>
  #2 (permalink)  
Old January 16th, 2006, 07:00 PM
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

You dont have to set session variable values in your global.asa file. you can declaire them anywhere, reset them anywhere and reassign them anywhere. These changes take place while the sesion is existing.

Is that all the contents of your global.asa file? If so yoiu are missing some syntax. It should look something like:

<script runat=server language=VBScript>
sub application_onStart
end sub

sub session_onStart
    Session.Timeout = 40
    application.lock
    //do stuff
    application.unlock
end sub

sub session_onEnd
end sub
</script>

Additionaly have you made your web site a virtual dir?

Wind is your friend
Matt
  #3 (permalink)  
Old January 17th, 2006, 05:34 AM
Registered User
 
Join Date: Jan 2006
Location: Athens, Attiki, Greece.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply.
You are right the global.asa file is the following. However i have noticed that the session ID from in the first script is different than the ID in the second script (Like the second one starting a new session).

Global.asa:
========================= Global.asa ==============
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
</SCRIPT>

<OBJECT RUNAT=Server SCOPE=Session ID=ActConn PROGID="ADODB.Connection"> </OBJECT>
<OBJECT RUNAT=Server SCOPE=Session ID=UsrConn PROGID="ADODB.Connection"> </OBJECT>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
End Sub
Sub Application_OnEnd
End sub
Sub Session_onStart
    APPLICATION.Lock
    Session("MDB_Path") = server.MapPath("/Connections/v01.mdb")
    Session("UDB_Path") = server.MapPath("/Users/webus.mdb")
    Session("SES_Secured") = False
    SESSION("SES_TRY")= 0
        SESSION("Colored")= 0
    ActConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Session.Contents("MDB_Path") & ";"
    UsrConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Session.Contents("UDB_Path") & ";"
    APPLICATION.UNLOCK
end Sub
Sub Session_OnEnd
    ActConn.close
    UsrConn.close
    set ActConn = nothing
    set UsrConn = nothing

end Sub
</SCRIPT>
========================= Global.asa (end) ==============
  #4 (permalink)  
Old January 17th, 2006, 06:33 PM
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

I believe you should get another opinion on your global.asa file it looks wrong to me. To much information, to many <script> tags, to many <object> tags and why do you need your connection string in there?.

http://msdn.microsoft.com/library/de...1703c14fc0.asp

;;;However i have noticed that the session ID from in the first script is different than the ID in the second script

Do you mean?:
<OBJECT RUNAT=Server SCOPE=Session ID=ActConn...

That is not a session variable.

Wind is your friend
Matt
  #5 (permalink)  
Old January 18th, 2006, 06:47 AM
Registered User
 
Join Date: Jan 2006
Location: Athens, Attiki, Greece.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you again.
I think that it has nothing to do with the global.asa.
I changed the firt script to pass as queryString the current SessionID to the next script, and the second script to display the old session ID and its current . the result is that the first Session Id is different than the second one :

=========
Scr1.asp:
=========
<%
    Application.Lock
    session.Contents("Colored") = 1
    Application.UnLock
    Rlnk = "scr2.asp?SeSId=" & Session.SessionID
    Response.redirect Rlnk
%>
========
Scr2.asp
========
<%
Response.Write "Colored: " & Session("Colored:") & "<br>"
Response.Write "Previous Session Id: " & Request.QueryString("SeSId") & "<br>"
Response.Write "New Session Id: " & session.SessionID & "<br>"

%>

============= Results (as from scr2.asp) ===================
Colored: 0
Previous Session Id: 524219941
New Session Id: 524219945
============================================



  #6 (permalink)  
Old January 18th, 2006, 02:46 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Are you sure the folder that holds the global.asa file is an application? Otherwise, sessions won't work as expected.

And are you sure you don't have client software blocking your cookies? Since ASP Sessions depends on cookies, you need to be able to accept cookies from your server.

In addition to this: please do yourself a favor and review your code in the global.asa. Opening a connection in Session_Start and storing it in Session state is about the worst thing you can do to a web site. It'll run fine with just a few number of users, but you'll bring your entire site down to a grinding halt whenever more users hit your site. This practice is on the opposite end of "best practices for web development".

Also, there is no need to lock the application to set a session variable....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Erics Trip by Sonic Youth (Track 5 from the album: Daydream Nation) What's This?
  #7 (permalink)  
Old January 26th, 2006, 10:28 AM
Registered User
 
Join Date: Jan 2006
Location: Athens, Attiki, Greece.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I had created a new web side on my office server (IIS 5.0).
The Global.asa file is in the root folder of the Home path as appears in the "properties" in the "home directory" tab. Also i guess that in the same tab the entries in the "application settings" are indicating that it is an application?
  #8 (permalink)  
Old January 27th, 2006, 01:07 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, that sounds about right.

Do you have security software blocking cookies? Is IE set up to allow cookies?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #9 (permalink)  
Old January 30th, 2006, 09:38 AM
Registered User
 
Join Date: Jan 2006
Location: Athens, Attiki, Greece.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Guys it is solved!!!
The problem is that Sessions and Cookies are not functiong well when the WINS name of the server is being used instead of its IP address. So i changed the http://MyLocalServer:80xx/ to http://192.xx.xx.xx:80xx and worked !
Thank you everybody for the help.
 


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
clear variables contents - Please URGENT!! hugoscp Classic ASP Basics 3 November 29th, 2008 07:21 PM
session variables in asp to asp.net marvz ASP.NET 2.0 Basics 0 August 1st, 2005 03:09 AM
Passing Session Variables(ASP.NEt) to Jscript ank2go JSP Basics 1 February 26th, 2004 09:53 PM



All times are GMT -4. The time now is 12:40 PM.


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