2

I have users table containing all the user account details including a IsLoggedIn field with bit data type. I want to update any old rows with IsLoggedIn = 1 when a user starts new session before previous session expires. What is the best way to achieve this? Is it possible to do this with Trigger?

Thanks in advance..

2 Answers 2

1

You will have two things for sure.. 1) User ID and 2) Session Id in database.

Now when new session start (session_Start) event gets fire.. you can call one store procedure with logic and the logic will be

1) If there is not records with same userID do not do any update. 2) If there are any records with same userID update all of them with IsLoggedIn = 1.

You can extend this logic with TRIGGER as well and band it as per your need,.

Basically you need to track session_Start event and perform DB operations.

Sign up to request clarification or add additional context in comments.

1 Comment

so in my case session_Start is better than trigger isn't it?
1

Trigger won't be the suggested solution as you need to handle login from UI. If there is going to be only a single login then Application_Start can be used. If there can be multiple logins then Session_Start is preferable. From there you can give a call to database and perform the respective actions.
Difference between the two is explained at : http://forums.asp.net/t/1230163.aspx/1?What+s+the+difference+between+Application_Start+and+Session_Start+in+Global+aspx+

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.