The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automatic logout all userspice pages when one of them is logged out
#21
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).
  Reply
#22
I mean, the page gets refreshed every five seconds after I sign in, even if I just open one tab
  Reply
#23
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

  Reply
#24
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?
  Reply
#25
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
  Reply
#26
Okay, excellent. No need to post the JS then Big Grin
  Reply
#27
haha thanks a lot for all these help! you guys are amazing. Have a good weekend! Smile
  Reply
#28
Your words of encouragement are appreciated.
  Reply
#29
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.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)