Forums / Developer / How to use Session ?

How to use Session ?

Author Message

Florent Hache

Tuesday 13 October 2009 1:51:31 am

Hi everybody,
I search on internet and on the Ezpublish documentation but i don't see anythings about the use of session, i see a lot of documentation about the configuration in the site.ini but nothing about the use in a template = ...
Is there a sessions_start() like php or a session is create by default ?
And after how to create a variable sessions and how to access to the variable ?
If you have a documentation or just an example ?
Thanks a lot
Florent Hache

Gaetano Giunta

Tuesday 13 October 2009 2:30:59 am

There is no need to call session_start anywhere in your code: eZPublish always starts a session for every visitor of the site, even anonymous ones.
If you want to access (or set) session variables from templates, you can create custom template operators.

Principal Consultant International Business
Member of the Community Project Board

André R.

Tuesday 13 October 2009 4:57:04 am

Alternatively if this is for logged in users you can use ez preference witch is supported by the view cache system, and therefor will save you some headache. You set them with user/preferences/<key>/<value> and it will redirect back to referrer, and you control which one of them affect view cache with site.ini[ContentSettings]CachedViewPreferences.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom