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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is SessionID static?

Status
Not open for further replies.

arst06d

Programmer
Nov 29, 2002
324
Hi

I want to use the sessionid as part of a filename. On pageload, I check to see if that file exists - if not copy a template file and name it with the sessionid.

Code:
Dim fileExists As Boolean
        fileExists = My.Computer.FileSystem.FileExists("Session.SessionID & ".xml")
        If fileExists Then
            'use it
        Else
            'create it
            My.Computer.FileSystem.CopyFile("BACSPaymentTemplate.xml", "Session.SessionID & ".xml")
        End If

I'm using Web Developer Express 2005 on XP Pro sp2.

The above code always seems to create a new file. I thought sessionid was static during the life of the session - this indicates that it changes between postbacks.

Can someone please advise on this?
 
The sessionID is static. I am not sure even how your code is compiling, much less running.
 
Well - it is doing both!
What's the syntax error that makes you think it shouldn't compile?
 
First My.Computer.(What Imports are you using to get this to work?)
Second the string for the fileexists is incorrect
FileExists("Session.SessionID & ".xml")
it should be
FileExists("Session.SessionID" & ".xml")
 
Jim,

The My class is a class from version 2.0 of the framework and is perfectly valid. As for the FileExists, shouldn't it actually be:
Code:
FileExists(Session.SessionID & ".xml")
i.e. no quotes around the Session ID.

You are right that it shouldn't compile though, as there is an erroneous quotation mark in there.



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ahh I thought this was a 1.1 question. didn't realize this was available in 2.0. Also, you are correct with the quotes, no quotes around session id.
 
WOW, now I am really confused. I checked session.sessionID in v1.1, it remains static. I just checked it in v2.0 and it is changing on every post back!! What the hell????
 
That usually occurs when there is no session node in the web.config file or when there is no Session_Start event in the global.asax file. ASP.NET generally turns of session support when there are no event handlers for it and that seems to be what is happening. Try checking your web.config file and see if the session node is missing.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
In my 1.1 project I have not added anything to the global asax, and the session remains static.
In my 2.0 project, there is no session node in my web.config, and the session ID is changing... ?????

Any ideas ca8msm?
 
I'm not really sure to be honest! I though by specifying a sessionState entry in the web.config file, that it would resolve the changing ID. I'll have to come back to this once I've done a bit of digging!

As for the posters problem, perhaps you could create a new GUID and store that in session instead.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Very strange.. I added the sessionState entry in my 2.0 proj, stil the same thing. And what happend to the global.asax in 2.0?
 
Hi

Thanks for all the input. Seems I've stumbled across something bigger than I thought - glad it's not just me!

JBenson001 - regarding the syntax (stray ") - that is my fault - I copied the code into the post and then edited it, forgetting to take out the ".



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top