logout
logout
I have my logout page which destroys the session and sets the logged_in value in my database 2 0.. (so they dont show on the users online anymore) but my problem is.. if they just close the browser without logging out.. it logs them out obviously because the browser destroys the session but the site says they are still online.. how would i do it so i can set the logged in value to 0 if they close the browser without loggin out?
I would put a signature.. BUT, i don't have the time.
Re: logout
You can't is the short answer.
If you base the users online thing on the users that loaded a page in the last 5 minutes it will give you the desired effect.
If you base the users online thing on the users that loaded a page in the last 5 minutes it will give you the desired effect.
Re: logout
yeah but what im saying is, it doesnt matter how long i say.. say i stayed logged in and close my browser the site would say im online all day.. doesnt do that on phpbb i get logged out and removed from the thingy even if i do just close my browser so there must be a way..
I would put a signature.. BUT, i don't have the time.
Re: logout
yeah which must be stored in the database.. so when i click off my browser somehow it removes me from the database?jacek wrote:phpbb bases the users online on activity over the last 5 minutes like I described.
I would put a signature.. BUT, i don't have the time.
Re: logout
no, when you close your browser window you stay logged in for an additional 5 minutes, and then you get removed.ashwood wrote:yeah which must be stored in the database.. so when i click off my browser somehow it removes me from the database?jacek wrote:phpbb bases the users online on activity over the last 5 minutes like I described.
Re: logout
Also no,Temor wrote:no, when you close your browser window you stay logged in for an additional 5 minutes, and then you get removed.
The time you were last active is update every time you load a page, nothing is removed from the database but the time stops being updated if you close the browser.
Re: logout
how does it know ive closed my browser though? really dont get this...
I would put a signature.. BUT, i don't have the time.
Re: logout
jacek wrote:Also no,Temor wrote:no, when you close your browser window you stay logged in for an additional 5 minutes, and then you get removed.
The time you were last active is update every time you load a page, nothing is removed from the database but the time stops being updated if you close the browser.
ahhhh... how do i do this sort of thing then?
I would put a signature.. BUT, i don't have the time.
Re: logout
That's kinda what I meant, I just naturally assumed you refreshed/loaded the page right before closing the window ( that's what I do... )jacek wrote:Also no,Temor wrote:no, when you close your browser window you stay logged in for an additional 5 minutes, and then you get removed.
The time you were last active is update every time you load a page, nothing is removed from the database but the time stops being updated if you close the browser.
Re: logout
Don't ask silly questions ! On;y one of those can work with mysql.ashwood wrote:is it php? ajax? jquery?
Re: logout
lol sorry, so where do i go in php then? because im thinking i must need to set a timer? OR do i send the time to the database they logged in... then everytime they click a page that time updates BUT in the background have a jquery timer counting in a php file that looks in the database every 5 minutes and if the time is 5minutes less than the current time then remove that person from online users?
edit: sack the jquery timer is there a php function for current time? time()? ive never had to use anything like time or date yet..
edit: sack the jquery timer is there a php function for current time? time()? ive never had to use anything like time or date yet..
I would put a signature.. BUT, i don't have the time.
Re: logout
Hypothetically speaking, couldnt you use the window object in JavaScript, and use that to see if the browser has closed, and if it has; run the php/mysql code?
Re: logout
*facepalm* ... no.ashwood wrote:in the background have a jquery timer counting in a php file
Yes but the problem there is that the browser runs the javascript, so if its closed ...JelvinJS7 wrote:couldnt you use the window object in JavaScript, and use that to see if the browser has closed
You do not need to do anything when they close the window, or log out. You need to update the time they last loaded a page when they load a page.
Re: logout
so do i do what i said? when they log in.. send the time to the database.. then everytime they load a page send the time to the database.. over the top of the old one obviously.. then have a php file that checks every 5 minutes the time on all users and if the time is 5minutes less than the time it is now then remove that user from online users?jacek wrote: You do not need to do anything when they close the window, or log out. You need to update the time they last loaded a page when they load a page.
i have a idea of how to do it in my head.. can you confirm that, that is how i would do it?
I would put a signature.. BUT, i don't have the time.
Re: logout
Yes.ashwood wrote:so do i do what i said? when they log in.. send the time to the database.. then everytime they load a page send the time to the database.. over the top of the old one obviously..
You could, but you could also just leave the info in the table and use something likeashwood wrote:then have a php file that checks every 5 minutes the time on all users and if the time is 5minutes less than the time it is now then remove that user from online users?
SELECT `username` FROM `users_online` WHERE `last_online` > (UNIX_TIMESTAMP() - 300)to get the users online in the last 5 minutes.
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: logout
you can do it with a very small java applet.. making it fairly useless, sicne people need to accept java applets to run.
But;
you can use the stop() method in an applet, and get it to fire a script that logs them out of the database too.
The way this works is whenever the browser is closed (by the cross, Alt F4 or whatever way they do it) it fires that method before it closes.
http://www.cafeaulait.org/course/week5/28.html
But;
you can use the stop() method in an applet, and get it to fire a script that logs them out of the database too.
The way this works is whenever the browser is closed (by the cross, Alt F4 or whatever way they do it) it fires that method before it closes.
http://www.cafeaulait.org/course/week5/28.html
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Re: logout
That's quite an important point. Most people would reject it if they were not expecting to be asked to run an applet . Interesting proof of concept though.bowersbros wrote:making it fairly useless, sicne people need to accept java applets to run.
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: logout
yeah, pity you cant run something similar with just javascript or something, to get it to work without being accepted.jacek wrote:That's quite an important point. Most people would reject it if they were not expecting to be asked to run an applet . Interesting proof of concept though.bowersbros wrote:making it fairly useless, sicne people need to accept java applets to run.
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9