The following warnings occurred: | ||||||||||||||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Automatic logout all userspice pages when one of them is logged out - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Automatic logout all userspice pages when one of them is logged out (/showthread.php?tid=281) |
Automatic logout all userspice pages when one of them is logged out - brian - 09-23-2016 To debug it, you can try replacing the javascript...replace the following: if (data != '0') {window.location.replace(data);} with this: if (data != '0') { alert("Refresh"); }else{ alert("Nothing"); } That should display "Refresh" when the return from the PHP page is the refresh URL, and "Nothing" when it should be doing nothing. Maybe that will help? I think things were working okay for me, but perhaps it was refreshing and I just didn't notice. *edit* It could be another bug too...feel free to paste what you think is relevant and I can look through it. I just checked again and it seems to be working fine in my case (i.e. no refresh except when the certain conditions are met). Automatic logout all userspice pages when one of them is logged out - Angel - 09-23-2016 I mean, the page gets refreshed every five seconds after I sign in, even if I just open one tab Automatic logout all userspice pages when one of them is logged out - Angel - 09-23-2016 Oh I think one thing I didn't mention is that the php file outputs a '0' when the user is logged in, right? I observed on my page that after 5 seconds, the page url is added a 0 in the end. for example, after I sign in to http://localhost:8060/userspice/usersc/ for 5 seconds, the page gets redirected to: http://localhost:8060/userspice/usersc/0 I then changed the 0 in your code to be just empty string..............maybe that's a stupid change......But I just re-do the implemented, it still gets redirected to url+0 Automatic logout all userspice pages when one of them is logged out - brian - 09-23-2016 Okay, that means the logic is backwards somewhere....the redirection should only happen when it doesn't get 0 back...can you paste your JS here? Automatic logout all userspice pages when one of them is logged out - Angel - 09-23-2016 issue solved....... It is a really weird cause. I added alert(data) inside the if (data == '0') loop, I find that it alerts 0 after 5 seconds, but your code already specified that it executes inside the if loop if data is not 0. So somehow the 0 from the posted data is not recognized as 0 by the if statement..... I changed the if statement from if (data == '0') to be: if (isNaN(data)) everything works perfect now....Thank you so much for the code! Angel Automatic logout all userspice pages when one of them is logged out - brian - 09-23-2016 Okay, excellent. No need to post the JS then Automatic logout all userspice pages when one of them is logged out - Angel - 09-23-2016 haha thanks a lot for all these help! you guys are amazing. Have a good weekend! Automatic logout all userspice pages when one of them is logged out - brian - 09-23-2016 Your words of encouragement are appreciated. Automatic logout all userspice pages when one of them is logged out - plb - 09-30-2016 Thanks for implementing this as documentation for users to add if they want this functionality rather than part of UserSpice. I think this would be a Very Bad Idea to put in as part of vanilla UserSpice. |