Jump to content
thomas

Check if $user is logged in without renewing cookie

Recommended Posts

I'm building my first AngularJS app on top of Processwire and I was wondering how I could check if the user is still logged in and has the neccessary permissions without actually renewing the cookie lifetime? On manual logout I could pass some session variable but if the session simply runs out (like leaving the browser window open over night) I'd like to periodically check $user and re-route to a log-in page when the session expires, but this seems to renew the cookie ...

Can anyone help?

thanks, thomas

Share this post


Link to post
Share on other sites

Hi thomas,

I'm not sure if my thougths are helpful and also if I got it right what you need to achieve. You have a js app that "talks" to the server, (through ajax or alike?) when it has to read or save data through PW?

Why would you trigger poll requests if you don't have anything to do for the app or server? I mean, you can check on top of each regular request that needs to interact with PW as logged in user if he still is logged in, and if not, redirect to the login screen. (maybe?)

Or maybe you can set a special session variable (timestamp) for logged in users that gets updated only on regular requests, not on poll requests. This session var needs to be used / bind for the logout timeout then. (but also don't know which hook would be needed for that)

When reading my answer now, it doesn't look very helpful at all. :)  (but I have tried it!)

Share this post


Link to post
Share on other sites

Hallo Horst,

thanks, that was actually quite helpful! My app reads alot of (personal) data on start up and only polls PW when data is edited. That's why I'd like it to log out when it sits idle for a wile. I already thought about using a timestamp in a session so that's want i'll try to do.

Thanks,

thomas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...