would really appreciate any help with this JS question.
Have been experimenting for an hour or so now and haven't bumped into anything that does the trick.
Current Setup
- Website 1: the 'content' site. This site displays different content depending on whether a user is logged into website 2 or not. I'm using a script tag in the head with the src set to a PHP file located on website 2.
- Website 2: the 'user management' site. This uses PHP to output in a 'javascript' file whether a user is logged in (i.e. as a js var).
Currently this setup works fine for checking whether a user is logged into website 2 system when a user loads the page on website 1.
However, rather than a once-off check, I'm wanting the PHP file on website 2 to be polled every 2 seconds to see if the loggedin status has changed.
Is there a way to do this in vanilla javascript? (i.e. without ajax or jq - I'm trying to keep the whole system small and known).
If it's relevant, a friend suggested putting a randomly generated variable at the end of the PHP file name to prevent caching. (He didn't know how it could be repeatedly polled though!)