Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

session on 1 page


Go to End


4 Posts   1482 Views

Avatar
dreezy

Community Member, 9 Posts

21 December 2010 at 5:25am

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

Avatar
dompie

Community Member, 88 Posts

23 December 2010 at 9:54am

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.

Avatar
SSadmin

Community Member, 90 Posts

27 January 2011 at 4:49pm

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

Avatar
dompie

Community Member, 88 Posts

28 January 2011 at 2:36am

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.