Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Using sessions with smarty?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
lojmann
Smarty n00b


Joined: 31 Jan 2004
Posts: 1
Location: Malmö, Sweden

PostPosted: Sat Jan 31, 2004 11:20 am    Post subject: Using sessions with smarty? Reply with quote

Hi,

Is it possible to use sessions in my tpl-files?
I've try but it wount work!

I've try to assign my session vars, but it dosen't work...

Please help me!
_________________
/Lojmann
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat Jan 31, 2004 1:48 pm    Post subject: Reply with quote

I have used sessions with smarty many times. Just use {$smarty.session.var} to get the variable 'var'.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
gianni
Smarty Rookie


Joined: 14 May 2003
Posts: 29
Location: Bari, Italy

PostPosted: Sat Jan 31, 2004 2:08 pm    Post subject: Reply with quote

Is it possible to use this?
{$smarty.session.object->var}
or this?
{$smarty.session.object->method()}
_________________
PHPnews.it Notizie dal mondo PHP e dintorni
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat Jan 31, 2004 3:51 pm    Post subject: Reply with quote

I would imagin the first is possible, but the second given the nature that PHP serializes the objects variables only would require you to declare a new class and assign the unserialized session variable to it then it would retain all properties as before and you could possibly call methods. I havn't tested it but if my understanding of Smarty is right it should work.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Jan 31, 2004 4:12 pm    Post subject: Reply with quote

@gianni: the former works since 2.6.0, the latter works not.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
terryjohnson
Smarty Rookie


Joined: 03 Jan 2004
Posts: 9
Location: Chatham, ON, Canada

PostPosted: Wed Feb 04, 2004 9:18 pm    Post subject: Session object method call work in foreach, but not alone? Reply with quote

I don't understand why $smarty.session.object->getData() does not work but this does:

Code:

{foreach item=object from=$smarty.session.objectarray}
{$object->getData()}
{/foreach}


It is possible to make a direct method call work? It would save a lot assigning objects by reference just to give them a simpler name.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP