Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Check whether a certain user is Logged In or Have a valid session
  • Check whether a certain user is Logged In or Have a valid session

    Or list of users who is loggesd in currently
  • HarroHarro
    Accepted Answer
    Is not really possible.

    We've seen people extend the Session DB driver, to include the current user_id as a column in the session table, or 0 if no user logged in. You can then run a query with user_id <> 0 and timestamp < time() + 60, for users active in the last 60 seconds. You can change the number depending on what you consider "logged in".

    For other session backends, it is either a lot more complicated, or impossible (in case of cookie based sessions).

    Alternatively, extend your users table with a "last_active" column, and extend the perform_check() method of your auth class to update this column after a successful check. You can then run the query against the users table.

    Something like:

    protected function perform_check()
    {
        if ($result = parent::perform_check())
        {
            // update the db here
        }

        return $result;
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion