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

Authentication with session variables?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,
How to use session vars to authenticate users?
For example:
if one user is logged in - Session("userID") will get his ID value.
Then, if another person is trying to go to the password protected page and types in his name and password what happens with the first user?
Will Session("userID")get a new value? or new session with the same name is created for each user?

Is there a good way of using session variables for authenticating and storing information about each user (create an array and store it there, maybe?) or I have to connect to DB on each page for authentication or pass Form/Srting variables everywhere?
Thank you.
 
hi axa777,

I got your problem.You do this.
First show the login page where a user enters his uid and pwd. On submit the action should go to an intermediate page which checks the authenticity of the user. If u find the user valid then only give hime the session("uid")=myuid and redirect him to the next page.
If he is not authentic redirect him again to the login page with out giving his name in the session("uid").


I hope this will solve your problem.


sincerely,
rdsmadhu
 
Thanks rdsmadhu,

My question is this:
What happens if MANY users will login at the same time?

Do they use the SAME session variable?
How to keep in the session variable information about each user?
I have many pages which should be not accessable by unauthorized users.
How do I check on EACH of these pages if EACH of the logged in users is authorized?
 
P.S.
I shoul've said:
how do I pass userID from one protected page to another for multiple users using session variable?

Thanks

 
But 777axa, each user has his own username which is unique.
if you call session("uid") it returns the username of the current user and not somebody else. this is valid in any page until the session is timed out.



*********************
Sincerery rdsmadhu.
*********************
 
Session variable sets are unique for each user, if you have 500 users logged in with Session("uid") set, than you have 500 copies of the session variable resident in RAM each keyed to a unique key for a specific user. This key is stored as a client side cookie and is used by the server to decide which one of the many copies of the session("uid") it should bring back when you request it.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Thank you rdsmadhu & Tarwn,
I wasn't sure if each time a new unique session variable is created for each user.
Do you think that if it would be enough just checking if session("uid") is not empty on the rest of password protected pages?

Re: cookies. If I understand correctly - they are created each time when a new session variable is initialized and requested each time this session is referred to, correct?
Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top