Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Variable Not Retained From Page to Page

Status
Not open for further replies.

scripter73

Programmer
Apr 18, 2001
421
US
I have an application that is written in ASP that provides a GUI interface to allow users to retrieve image files. This application also utilizes ActiveX controls to execute VB DLLS.

I want to create a custom application off of this main application. Now suppose this application’s location is c:\test\app1\. I’m putting my initial code in \app1\ as well. The \app1\ directory contains the global.asa file that sets many session and application variables.

My first template is to login to a library and requires many include files in order to work. When I run the template, it is successful (gives the user a popup). It established many session variables that were necessary, such as the library’s name. Now when I goto another template I’ve created, it tells me no session variable exists.

What am I doing wrong? Also, does anybody know of a template out there that will list all of my existing session variables? Let me know if I need to post code. There’s just so much, I don’t want to list too much.

Any help you can give is appreciated.

Scripter73

Change Your Thinking, Change Your Life.
 
<%
session(&quot;myVar&quot;) = &quot;Hard Worker&quot;

for each item in Session.Contents
Response.Write item & &quot; = &quot;
Response.Write Session(item)
next
%>


Have you made sure you have set c:\test\app1\ as a virtual directory and created an application on this folder in IIS?

Thanks,

Gabe
 
Hi again, GabeC!

Thanks for your help (again!) Well, I put the code you gave me a template like the following:


<html>
<head>
<title>Show Existing Session Vars</title>
</head>

<body>

<%
session(&quot;myVar&quot;) = &quot;Hard Worker&quot;

for each item in Session.Contents
Response.Write item & &quot; = &quot;
Response.Write Session(item)
Response.Write &quot;<br>&quot;
next
%>

</body>
</html>




And it did list about 2 vars, and then when it got to displaying the ErrorManager sess var, I got:

Response object error 'ASP 0185 : 80020003'
Missing Default Property

?

A default property was not found for the object.


Also, about the directory, the program is in c:\inetpub\ Yes. The virtual directory is created.

Thanks for your help.

scripter73
Change Your Thinking, Change Your Life.
 
No, that fixed it. :) Thanks.

Well, I don't know what the trouble could be. On one page I login, and it confirms the login. There's a session variable (LibraryLogonIDs), that keeps track of all logged on libraries.

When I type in my page that displays the session variables, they should be set, right? I try to view these vars in both the same browser session I used to login and a different one. The session variables are all blank.

Any ideas? Keep in mind I'm a relative newbie.

Thanks.
Change Your Thinking, Change Your Life.
 
GabeC's code should have outputed something like this
count1 = 56
count = 529
start = 11/11/2002 3:38:37 PM
myVar = Hard Worker

did it?

A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Well when I first ran it I got the error mentioned above about a Missing Default Property. Then I added the quotes in Session(&quot;item). I didn't receive any errors, but I didn't receive any values either, just a list like:

count1 =
count =
start =

Now I took the quotes out again, and ran the template and it is taking a long time and is returning nothing.

Let me ask you this. A couple of the sessions are defined like this:

set Session(&quot;ErrorManager&quot;) = server.CreateObject(&quot;idmError.ErrorManager&quot;), where idmError is a type library specific to my main application. Could this be why I can't just &quot;display&quot; the session contents?

Thanks for your help.
Change Your Thinking, Change Your Life.
 
seeing as the code that GabeC gave you failed to run I would not be concerned with your code at this point. in some palce session variables are not being executed on your system.
check these options
First: Cookies must be enabled for session varaibles to work properly.

Second: follow these steps in IIS
1. Start ISM.
2. If you use your Web server's virtual directories, expand the folders until you see the virtual directories, then right-click the virtual directory that you want to change. Otherwise, right-click the Web server that you want to change.
4. Select the Virtual Directory tab for a virtual directory or the Home Directory tab for a Web server.
5. Click Configuration.
6. Select the App Options tab, which Screen 2 shows.
7. Make sure the Enable session state check box is checked if not check

also try placing in the page
Enablesessionstate=True A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Hi onpnt,

Thanks for your suggestions. I have verified that Session States are enabled in the App Options tab.

GabeC's code is right on target in terms of displaying the session vars. Keep in mind I'm trying to carve a custom application out of an existing application. I'm dumping my code in the existing application's directory, and then running the code. Actually, I know the code is correct, because it was given to me from this company. I'm just trying to run it to get familiar with it so I can tweak it later. I do get the values of some session varaibles. My main problem is that while I'm printing out my session variables, it gets to a particular session variable that is of a custom type. How do I print (or find out) the contents of that custom session variable? Is that possible? The variable's type is specifically defined in the application. I think its a VB DLL.

Thanks for your help.
scripter73
Change Your Thinking, Change Your Life.
 
Thanks, onpnt,

I read over the article. I really only saw the first page. But I guess there's no way to actually print out the content of an object without explicitly stating it.

But check this out. I found another thread thread333-129387 called &quot;Viewing Sessions&quot; that has a great template for displaying session variables. It also tells you if it is an array, object, etc. After I ran it, it confirmed that I was indeed trying to display an object. But it did tell me my other session variable contents.

Many thanks for helping, GabeC and onpnt! I'll probably be talking with you later.

scripter73
Change Your Thinking, Change Your Life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top