|
 |
aspx_beginners thread: SessionID
Message #1 by "Dan McKinnon" <mddonna@q...> on Thu, 30 May 2002 06:57:00
|
|
Can anyone give me some direction as to how to access the SessionID? I
should be able to figure it out, but haven't had success so far. (This is
the beginning forum, after all)
Dan
Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 29 May 2002 23:00:52 -0700
|
|
Dan,
It's simply Session.SessionID.
Hope this helps,
Minh.
-----Original Message-----
From: Dan McKinnon [mailto:mddonna@q...]
Sent: Thursday, May 30, 2002 6:57 AM
To: aspx_beginners
Subject: [aspx_beginners] SessionID
Can anyone give me some direction as to how to access the SessionID? I
should be able to figure it out, but haven't had success so far. (This
is
the beginning forum, after all)
Dan
Message #3 by "Dan McKinnon" <mddonna@q...> on Fri, 31 May 2002 00:50:13
|
|
> Dan,
It's simply Session.SessionID.
Hope this helps,
Minh.
You know, I could not get the code below to work last night (at least I
think I remember trying it, or something like it), but it works today
(after rebooting computer, etc.). Because it didn't work I tried for an
hour doing various things. I created a new httpsessionstate object, etc.,
etc. I was getting two error messages primarily, 'can't access a non-
shared member', and 'need to create an instance of the object before
accessing it'.
<%@ Page debug = "true" %>
<%@ Import namespace = "System.Web.SessionState" %>
<script runat="server">
Private Sub Page_Load()
Dim y as string = session.sessionid
Response.write(y)
End Sub
</script>
So your post did help me. Now my question is, when I create an identical
page and go to it, it displays a different sessionID. Even if I just
refresh the same page, it instantiates a new sessionID for that page! I
thought the sessionID was supposed to remain the same for my entire
session.
Thank you,
Dan
Message #4 by "Minh T. Nguyen" <nguyentriminh@y...> on Thu, 30 May 2002 17:12:11 -0700
|
|
Dan,
Hm. It should be working. I copied and pasted your code into a
file of mine, converted it into C# and it keeps displaying the same
session ID. Can you check your web.config and make sure that you don't
have cookieless set to true by mistake in your sessionState section?
Also make sure to have a browser that accepts cookies (this is how
session states are actually stored) and make sure that your page has
EnableSessionState is set to true (which by default it is). Other than
this, I can't explain why it would give you different values. Here's the
working C# version:
<%@ Page debug = "true" %>
<%@ Import namespace = "System.Web.SessionState" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e) {
string y = Session.SessionID;
Response.Write(y);
}
</script>
Good luck,
Minh.
-----Original Message-----
From: Dan McKinnon [mailto:mddonna@q...]
Sent: Friday, May 31, 2002 12:50 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: SessionID
> Dan,
It's simply Session.SessionID.
Hope this helps,
Minh.
You know, I could not get the code below to work last night (at least I
think I remember trying it, or something like it), but it works today
(after rebooting computer, etc.). Because it didn't work I tried for an
hour doing various things. I created a new httpsessionstate object,
etc.,
etc. I was getting two error messages primarily, 'can't access a non-
shared member', and 'need to create an instance of the object before
accessing it'.
<%@ Page debug = "true" %>
<%@ Import namespace = "System.Web.SessionState" %>
<script runat="server">
Private Sub Page_Load()
Dim y as string = session.sessionid
Response.write(y)
End Sub
</script>
So your post did help me. Now my question is, when I create an identical
page and go to it, it displays a different sessionID. Even if I just
refresh the same page, it instantiates a new sessionID for that page! I
thought the sessionID was supposed to remain the same for my entire
session.
Thank you,
Dan
|
|
 |