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.

Archive /

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

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

Accessing Session values in templates


Go to End


2 Posts   3595 Views

Avatar
Cfu

Community Member, 1 Post

30 October 2008 at 11:16am

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

Avatar
Willr

Forum Moderator, 5523 Posts

30 October 2008 at 12:13pm

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