How to get a session value? - WeOnlyDo Discussion board

How to get a session value? (wodWebServer / wodWebServer.NET)

by Jeremy, Tuesday, October 28, 2014, 09:43 (3439 days ago)

I write some code in RequestDoneEvent to get session value saved in asp.net.

It always return nothing.

Ex:

If Not Args.User.SessionVars("ConnectDate") Is Nothing Then
AddTraceLine(Args.User.SessionVars("ConnectDate").ToString())
End If

How to get a session value?

by Jasmine, Tuesday, October 28, 2014, 10:56 (3439 days ago) @ Jeremy

Hi Jeremy.

Can you tell me where do you set ConnectDate session variable? Or you can attach sample project and send it to techsupport so we can try it out.

Warm regards.
Jasmine.

How to get a session value?

by Jeremy, Wednesday, October 29, 2014, 03:10 (3439 days ago) @ Jasmine

Hi Jasmine,

This is a simple sample.

In the ASP.NET Page_Load Event

If Session("ConnectDate") = "" Then
Session("ConnectDate") = Now.ToLongTimeString()
End IF

Label1.Text = Session("ConnectDate")

I need a sample to read the session value in wodWebServer.Net.

BTW, the sample in online help does not work.

WebServer.NET/Help/wodWebServer.NET-WeOnlyDo.Server.WebUser-SessionVars-property.html

If User.SessionVars.Exists("MyCount") Then
User.SessionVars("MyCount") = User.SessionVars("MyCount") + 1
Else
User.SessionVars.Add("MyCount").Value = 1
End If

I could not find a method named "Exists"

How to get a session value?

by Traveller, Wednesday, October 29, 2014, 09:09 (3438 days ago) @ Jeremy

Hi,
I think that if you see the line of code of yours below:

Label1.Text = Session("ConnectDate")

Label1.Caption = Session("ConnectDate") , should have been used instead !

I don't know if Lable control has text property ?

Label has TAG & Caption properties as I checked my VB6 Software.

and may be that is why you see no return value.

Regards.

How to get a session value?

by Jasmine, Wednesday, October 29, 2014, 10:05 (3438 days ago) @ Jeremy

Hi Jeremy.

I think you're accessing ASP.NET's Session object when setting the Session, and then accessing User.SessionVars from wodWebServer.NET. These are two different collections, and we can't access ASP.NET's session collection.

Can you try to set it through User.SessionVars collection?

Kind regards.
Jasmine.

How to get a session value?

by Jeremy, Wednesday, October 29, 2014, 10:12 (3438 days ago) @ Jasmine

Thanks.