Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am new in asp.net, need a bit help. I am working on a website this website Have a user Login page. I want save a records in database who User login and when goes out website.I have some idea about the Global.asax. I Want save the records when fire
C#
Session_End()
in Global.asax. I don't have any idea about this problem. Thanks for help Advanced.
Posted
Comments
Richard C Bishop 12-Dec-13 14:53pm    
For starters, you need to set the SessionState to "InProc" in your web.config.
joginder-banger 12-Dec-13 15:01pm    
Where are the declared table and store procedure???
creepz03 12-Dec-13 21:00pm    
I dont get it at all.. If you want to save the user who logs in/out then just save it on the database the way you want it to be saved. Can't seem to find the reason as to why you need the session for this.
joginder-banger 12-Dec-13 23:11pm    
sir if user can't fire logoff button,then how can save the log out time in database?
creepz03 13-Dec-13 0:05am    
Then you should re-phrase your question. Do you mean saving Log In/Out when session expires?

1 solution

You can use Session_Start() to store when they login but I would recommend having a login page and do the logic in your login validation code instead.

Session_End() is not guaranteed to fire. Because the web is a disconnected medium there is no way to make sure users are not logged in. What you can do, if you really need to know who is logged in, is every request a user makes you update a table indicating they are logged in. Then you can check the table for anyone who has not made a request within the last x number of minutes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900