timing out

14 views
Skip to first unread message

Arbee

unread,
Aug 5, 2017, 2:58:19 PM8/5/17
to SilverStripe Core Development
I'm hoping this is ok to ask here. I'm using SS 3.6 and have a login area for frontend users on my website. They are getting timed out too soon while idle. With the nature of my website, they can be idle for an hour or more but don't want to be automatically logged out. How or where can I change that length of time? I am using the forum module so not sure if it is something in there. Can anyone point me in the right direction, please?

Colin Burns

unread,
Aug 5, 2017, 3:05:12 PM8/5/17
to silverst...@googlegroups.com
If you don't want the user to logout you could create a method that just returns a boolean true value.

Then create a small js script that makes an AJAX call to this function every 30 minutes or so which will keep the users session alive.

So add this to one of your Controllers (example Page.php - although you might want to add it to your password protected page)

Remember to set private static $allowed_actions = array ('ping');

    /**
     * Keep the session alive for the user.
     *
     * @return int
     */
    public function ping() {
        return 1;
    }

Then in your JS - I am using jQuery

    /*************
     * JS to keep the session alive
     */
    setInterval(function() {
        // Ping every 3 mins.
        $.ajax({url: "/<your page name>/ping"});
    }, 180*1000); // Run this every 3 minutes


Cheers,
Colin


Colin Burns
Canada: +1-250-899-1204
Australia: +61 7 3102 4334
Twitter: @ccburns
Email: ccb...@gmail.com


On Sat, Aug 5, 2017 at 11:58 AM, Arbee <ru...@arbeedesigns.com> wrote:
I'm hoping this is ok to ask here. I'm using SS 3.6 and have a login area for frontend users on my website. They are getting timed out too soon while idle. With the nature of my website, they can be idle for an hour or more but don't want to be automatically logged out. How or where can I change that length of time? I am using the forum module so not sure if it is something in there. Can anyone point me in the right direction, please?

--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-dev+unsubscribe@googlegroups.com.
To post to this group, send email to silverstripe-dev@googlegroups.com.
Visit this group at https://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.

Tony Air

unread,
Aug 5, 2017, 3:07:09 PM8/5/17
to SilverStripe Core Development
Just ping to /Security/ping - no need to create new method or Controller 
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.

Colin Burns

unread,
Aug 5, 2017, 3:08:07 PM8/5/17
to silverst...@googlegroups.com
Oh cool - thanks I didn't know that :)

Cheers,
Colin

Colin Burns
Canada: +1-250-899-1204
Australia: +61 7 3102 4334
Twitter: @ccburns
Email: ccb...@gmail.com


To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-dev+unsubscribe@googlegroups.com.
To post to this group, send email to silverstripe-dev@googlegroups.com.

Arbee

unread,
Aug 5, 2017, 4:38:11 PM8/5/17
to SilverStripe Core Development
Oh that's very cool guys. Thanks so much for the help!
Reply all
Reply to author
Forward
0 new messages