Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » session on 1 page

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 829 Views
  • dreezy
    Avatar
    Community Member
    9 Posts

    session on 1 page Link to this post

    hey all,

    i've one page on my site where i need to handle with sessions

    at this page (its a page normal writen in the cms) i can't use php

    i need it to logout a user after 1800 seconds.

    how to handle with this?

    In the CMS i can't input the php that's needed for the session

    Thanx for reply

  • dompie
    Avatar
    Community Member
    88 Posts

    Re: session on 1 page Link to this post

    I'd solve this by
    1) writing a timestamp to the users session and a small javascript that informs the user that his session is going to time out. after the time period elapsed, i'll call a logout function on that page (see 'controller' and 'ajax_basics' on doc.silverstripe.org to get an idea of this).

    2) because javascript is not trustworthy, I would additionally do a serverside check. If user is also known to silverstripe, the 'Member' class might help you with that.

  • SSadmin
    Avatar
    Community Member
    90 Posts

    Re: session on 1 page Link to this post

    hey,dompie.

    I have came into the same problem.
    I also want to do a session time out for logging out a current user.

    1) writing a timestamp to the users session and a small javascript that informs the user that his session is going to time out. after the time period elapsed, i'll call a logout function on that page (see 'controller' and 'ajax_basics' on doc.silverstripe.org to get an idea of this).

    i have looked up the doc for silverstripe ajax part, still not too sure how to achieve a timer here to inform user here.
    any hint ?
    Thanks

  • dompie
    Avatar
    Community Member
    88 Posts

    Re: session on 1 page Link to this post

    Everything pure theory:

    Serverside
    1) On login: save logout time to session
    2) In Page->init(), before parent::init() check if value is present in session.
    3) if present, check if logout is requred and do it eventually
    4) eventually you want to write these values to your javascript file via javascriptTemplate (depends on your solution)

    Javascript
    1) check if logout time is set (in session and/or script)
    2) if present, check logout conditions and call a logout url
    3) for calling a logout url, it may be required to implement an url_handler to your responsible Controller. maybe silverstripe has already one present for logging out user.

    829 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.