Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Accessing Session values in templates

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1567 Views
  • Cfu
    Community Member
    1 Post

    Accessing Session values in templates Link to this post

    Hey guys,

    Hopefully someone can help me, im trying to access a session value I have set with Session::set("school", true); in a Page class file, but im unsure how to access it within a .ss file

    I have tried <% if Session::get("school") %> html code <% end_if %> among other things but nothing ive tried seems to work.

    Anyone able to point me in the right direction.

    Much appreciated

  • Willr
    Forum Moderator
    5502 Posts

    Re: Accessing Session values in templates Link to this post

    I dont think there is anything built into the template system for this. You will have to add a function on your Page.php or other code file in the controller part

    function SessionSchool() {
    return Session::get("school");

    Then access it will $SessionSchool

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.