I need to count number of sessions but it dose not work when I say if numbers of sessions are 2 then do something. The example below is my code:
// count curent session in order to keep two player
if (HttpContext.Current.Session.Count == 2)
{
Response.Redirect("update.aspx");
}
I place the above code in code behind. is there any other way that I can say: if number of sessions are 2 else do something...
This is the count of session variables stored in the session for that user (msdn reference)...not the number of user sessions that exist currently.
You will need to store the session count outside of the session itself...perhaps in the Cache or Application cache.
Here are some SO questions to help implement this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With