Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alternative to Session Variable
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Alternative to Session Variable
Miscellaneous
Thread ID:
01682699
Message ID:
01682699
Views:
40
Hi,

I am seeking an opinion on the following topic.

Briefly, my ASP.NET application has two pages (actually it has more but for this discussion two pages are sufficient)

The first page is a log in page where a user logs in. He/she enters his username and the password. The username and password is validated against a table in the DB and, if passed, the requester ID (PK) is stored in a session variable. E.g.
Session["UserPk"] = nUserId;
Then, next page is open where the user enters some order. After he/she fills out the order form, they click on Submit and the data is sent to the DB Stored Procedure. The Order form gets the nUserId from the session as follows:
nUserId = (int)Session["UserPk"];
The value of nUserId is sent to the Stored Procedure.

What I noticed (actually a customer brought to my attention) is that sometimes the value 0 for the variable nUserId is passed to the Stored Procedure. Which means that the Session variable didn't have any value. Or it expired. How, I don't understand.

This is why I asked yesterday on how to get the Authentication Mode. Now, I will check, in code, if the Authentication mode is Forms. Which means that nUserId must have a value greater than 0. And if the nUserId is 0, the program will not submit but show the error message. Something like, "Log out and log in again ..."

Does above seem like a good approach? Or should I replace the Session variable use with another approach?

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform