How to Maintian Who is online.
-
Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)
Kiran Banker
-
Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)
Kiran Banker
banker_kiran wrote:
If one of them close browser without sign out then he/she will not be displayed in list.
You can do this with AJAX. Otherwise, you have to wait for their session to time out.
banker_kiran wrote:
And also i want to restrict multiple login by one user in different browser.
Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)
Kiran Banker
Many times answered for the same question by different people. Try doing a serch on this discussion board.
-
Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)
Kiran Banker
To maintain online users, you should go with database. On closing browser using javascript onUnload event check the window size and if less than or equal to zero update the logout flag in database as false thru AJAX. On every time login show the online users with that flag as true.
Be simple and Be sample.
-
banker_kiran wrote:
If one of them close browser without sign out then he/she will not be displayed in list.
You can do this with AJAX. Otherwise, you have to wait for their session to time out.
banker_kiran wrote:
And also i want to restrict multiple login by one user in different browser.
Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.
Is it a good practice on believing javascript for this ? In a worst case scenario, what will happen if user system got hanged and need a restart ? So the flag there in user table still show he is online, and prevents him from logging again. I think there is no efficient methods for this. What do you say ?
-
banker_kiran wrote:
If one of them close browser without sign out then he/she will not be displayed in list.
You can do this with AJAX. Otherwise, you have to wait for their session to time out.
banker_kiran wrote:
And also i want to restrict multiple login by one user in different browser.
Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Hi, Thanks for Reply Can I check that current session_id is live or dead. If i get that then i can compare it with session id stored in database, if it is still live then i can restrict user from login.
kiranbanker
-
Christian Graus wrote:
Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.
Is it a good practice on believing javascript for this ? In a worst case scenario, what will happen if user system got hanged and need a restart ? So the flag there in user table still show he is online, and prevents him from logging again. I think there is no efficient methods for this. What do you say ?
If system is hanged, now he/or she has shutdown system, now he/she wants to login once again then. how do i change flag,
kiranbanker
-
Christian Graus wrote:
Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.
Is it a good practice on believing javascript for this ? In a worst case scenario, what will happen if user system got hanged and need a restart ? So the flag there in user table still show he is online, and prevents him from logging again. I think there is no efficient methods for this. What do you say ?
N a v a n e e t h wrote:
Is it a good practice on believing javascript for this ?
Well, AJAX is the only way you can find out if the browser was closed. It's wise to add code to manually clear sessions you know have timed out, also, if you must do this at all.
N a v a n e e t h wrote:
So the flag there in user table still show he is online, and prevents him from logging again.
That's the main reason that I said it's better to kill the old session and allow a new login to take precedence.
N a v a n e e t h wrote:
I think there is no efficient methods for this. What do you say ?
Yes, it's messy, no matter how you look at it.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
N a v a n e e t h wrote:
Is it a good practice on believing javascript for this ?
Well, AJAX is the only way you can find out if the browser was closed. It's wise to add code to manually clear sessions you know have timed out, also, if you must do this at all.
N a v a n e e t h wrote:
So the flag there in user table still show he is online, and prevents him from logging again.
That's the main reason that I said it's better to kill the old session and allow a new login to take precedence.
N a v a n e e t h wrote:
I think there is no efficient methods for this. What do you say ?
Yes, it's messy, no matter how you look at it.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
Yes, it's messy, no matter how you look at it.
Yes it is. It's not possible to believe on
session_end
also, which won't be fired all time, and it's specific for InProc. I have seen some examples which explains this in much more efficient way by making use of cache. Cache timeout will be set as session timeout time and assign a callback function when cache timed out. Inside this function we will be able to update the flag. This looks much closer to the problem. ?
-
Christian Graus wrote:
Yes, it's messy, no matter how you look at it.
Yes it is. It's not possible to believe on
session_end
also, which won't be fired all time, and it's specific for InProc. I have seen some examples which explains this in much more efficient way by making use of cache. Cache timeout will be set as session timeout time and assign a callback function when cache timed out. Inside this function we will be able to update the flag. This looks much closer to the problem. ?
With AJAX, you can capture a client side event when the browser is closed, and send a message to the server. That's what I was referring to. But, it's still messy. Turn the power off, that's the obvious example that you cannot code for.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )