How to use sessions while previewing items (1.3+)

Release 1.3 - ...

When previewing items that use sessions from the CMS Manager, you had to take extra measures, such as described in this article. If you didn't, you got the following exception:

Unable to use sessions because the item is not rendered by Asp.Net. 
You are probably previewing an item that uses sessions.
This is not yet supported.

From 1.3 onwards, previewing items with sessions has gotten a lot easier.

An appSettings value, 'SilentSessionAccess', is introduced for this.

XML CopyCode image Copy Code
<add key="SilentSessionAccess" value="true"/>

After setting 'SilentSessionAccess' to 'true', no errors will be raised you can simply use a default value in session.get().

Smartsite SXML CopyCode image Copy Code
{session.get(firstRequest, default=datetime.now())}


Note: The reason that session state is not suported from the Manager, is that previewing items from the CMS is actually done using a WebService call from the CMS to the Publication Server. In this interaction, state transfer is not possible.