When a user sets the option (remember me) and closes the browser and then opens the site again he does not appear listed with the on-line members.
How can I set a user to on-line
after the user reopens the site again?
I am using this code Membership.GetNumberOfUsersOnline();
but it returns 0 on-line
If by "sets the option" you mean sets the "remember me" flag. The reason for this is that this just sets a persistent cookie on the users computer. They are not "logged in" again afterwards. Thus, the Membership login never occurs again.
You need to perform some membership activity that has a "userIsOnline" flag, such as calling Membership.GetUser(username, true) to set the userIsOnline.
As an alternative , if you want to track users online, you could look at SignalR , see some tutorials here .
There's a post with a similar question here SignalR for tracking online users and chat .
and here signalR tracking connected users
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.