You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2007/12/11 09:45:13 UTC

REPOST: Altering session variables via flowscript

(Note: Posted this a month ago, no reply was offered
so I am trying again!)

Working with Cocoon 2.1.8.
 
I have set a session value for a user, using the session transformer 
in the sitemap.  I now want to alter that value, based on other 
conditions.
 
My sample testing flowscript code looks like:
 
//1. get user's current session  value
var _authContext  = contextMan.getContext("authentication");
var _currUserFrag = authContext.getXML("/authentication/colors"); 
var _currUserColors = Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOfNode(_currUserFrag);
print ("current Colors for user:" + _currUserColors);

//2. 
newColorID = "blue"
var newUserColors = _currUserColors + ',' + newColorID;
print ("new Colors:"+newUserColors);

//3. set new value in session
cocoon.session.setAttribute("cocoon.session.authentication.colors",newUserColors);

//4. check user's  new session value
_authContext  = contextMan.getContext("authentication");
_currUserFrag = authContext.getXML("/authentication/colors"); 
_currUserColors = Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOfNode(_currUserFrag);
print ("revised Colors for user:" + _currUserColors)
 
Part 1 might show a value of "red"; Part 2 then shows a value of 
"red,blue" but part 4 still shows a value of "red" - what needs 
to be different in the code?
 
Thanks
Derek


-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: REPOST: Altering session variables via flowscript

Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Derek,

sorry I missed the thread. Instead of adding it to the session, add it 
to the authentication context by using:

authContext.setXML("/authentication/colors", fragment)

Regards,

Jeroen Reijn


Derek Hohls wrote:
> (Note: Posted this a month ago, no reply was offered
> so I am trying again!)
> 
> Working with Cocoon 2.1.8.
>  
> I have set a session value for a user, using the session transformer 
> in the sitemap.  I now want to alter that value, based on other 
> conditions.
>  
> My sample testing flowscript code looks like:
>  
> //1. get user's current session  value
> var _authContext  = contextMan.getContext("authentication");
> var _currUserFrag = authContext.getXML("/authentication/colors"); 
> var _currUserColors = Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOfNode(_currUserFrag);
> print ("current Colors for user:" + _currUserColors);
> 
> //2. 
> newColorID = "blue"
> var newUserColors = _currUserColors + ',' + newColorID;
> print ("new Colors:"+newUserColors);
> 
> //3. set new value in session
> cocoon.session.setAttribute("cocoon.session.authentication.colors",newUserColors);
> 
> //4. check user's  new session value
> _authContext  = contextMan.getContext("authentication");
> _currUserFrag = authContext.getXML("/authentication/colors"); 
> _currUserColors = Packages.org.apache.cocoon.xml.dom.DOMUtil.getValueOfNode(_currUserFrag);
> print ("revised Colors for user:" + _currUserColors)
>  
> Part 1 might show a value of "red"; Part 2 then shows a value of 
> "red,blue" but part 4 still shows a value of "red" - what needs 
> to be different in the code?
>  
> Thanks
> Derek
> 
> 

-- 
Met vriendelijke groet,
Kind regards,

Jeroen Reijn

Hippo

Oosteinde 11
1017WT Amsterdam
The Netherlands
Tel  +31 (0)20 5224466


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org