See if something is causing an app pool recycling. If this is happening your session vars are getting lost. I had a similar problem with memory caching.
Its strange though that I can get the session in other XSL files :-S
Maybe I am missing some using statements?
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using umbraco.presentation.nodeFactory; using System.Data; using System.Collections; using System.Web.SessionState;
And then all I do in the page load is - Response.Write(umbraco.library.Session("lang").ToString());
Getting a session variable set in XSLT
Hi guys,
I have the folowing XSLT file which works great in getting back the session in other XSLT files:
<xsl:variable name="dlang">
<xsl:choose>
<xsl:when test="umbraco.library:RequestQueryString('lang') != '' ">
<xsl:value-of select="umbraco.library:RequestQueryString('lang')" />
</xsl:when>
<xsl:when test="umbraco.library:Session('lang') != ''">
<xsl:value-of select="umbraco.library:Session('lang')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$initlang" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="flang">
<xsl:if test="$dlang != '' and $dlang != $initlang ">
<xsl:value-of select="concat('_',$dlang)" />
</xsl:if>
</xsl:variable>
<xsl:template name="setlang">
<xsl:value-of select="umbraco.library:setSession('lang',$dlang) " />
</xsl:template>
<xsl:template match="/">
<xsl:call-template name="setlang" />
<xsl:value-of select = "$flang" />
</xsl:template>
However when I try and get the session in code eg:
umbraco.library.Session("lang")
Nothing is returned :-S
Any help would be much appreciated.
Thanks
Scott
Hi Scott,
See if something is causing an app pool recycling. If this is happening your session vars are getting lost. I had a similar problem with memory caching.
Dimitris
Hi Dimitris,
Its strange though that I can get the session in other XSL files :-S
Maybe I am missing some using statements?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.presentation.nodeFactory;
using System.Data;
using System.Collections;
using System.Web.SessionState;
And then all I do in the page load is - Response.Write(umbraco.library.Session("lang").ToString());
But nothing is returned :(
Thanks
Scott
Hi Scott, is the page with this code opening in a popup windows, or is it switching from http to https?
Hi Tim,
"Hi Scott, is the page with this code opening in a popup windows, or is it switching from http to https?" - Neither of these things are happening.
Thanks
Scott
Hi Scott,
I believe you can just use the standard .NET Session method
As the reference to umbraco.library:SetSession() is really just used to set and retireve the session in the XSLT's
Tom
is working on a reply...