Jump to content

Allow only one exclusive session for guest user


gebeer
 Share

Recommended Posts

Hello,

I need to restrict the page view of my app to a single guest user.

This means if a session for user guest is already open for that page, other guest users are not allowed to view the same page.

$session doesn't help much in that case as far as I can see from the docs (or maybe $session->getHistory() can help?).

I think I could approach it this way:

1. Set session storage to DB

2. Query session table in DB for open sessions for that page and act accordingly

Is there anything built into the API which I have missed that I can utilize to query the session table?

Or would I have to use $database and build my own query?

Any insight on this or idea how to tackle the problem would be much appreciated.

Link to comment
Share on other sites

Does it really have to be the "guest" user? As each new user is automatically a guest I think it'll be hard to prevent anyone being a guest. I'd simply create another generic user account, where you log in your "privileged" guest with forceLogin() and then you can at least differ between them. 

For getting active sessions you'd need to build any querying logic custom for your job. But the mysql query for the session db module can probably be copied from the module itself.

  • Like 1
Link to comment
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
 Share

×
×
  • Create New...