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

Could the $smarty reserved variable support sessions?

 
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 -> Feature Requests
View previous topic :: View next topic  
Author Message
Quille
Smarty n00b


Joined: 29 Sep 2008
Posts: 2

PostPosted: Mon Sep 29, 2008 2:57 pm    Post subject: Could the $smarty reserved variable support sessions? Reply with quote

I'm using a lot of sessions on my website.
I therefor wondered if it is possible to make the $smarty reserved variable support these...
Example:
Code:
{if $smarty.session.logged_in eq True}
<h2>You are logged in</h2>
{/if}

I think this addition to Smarty would be great. And since the $smarty variable already exists, why not expand it?
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Mon Sep 29, 2008 3:00 pm    Post subject: Reply with quote

No need for any expansion since it already supports it.
In fact, the code you posted should work perfectly.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
Quille
Smarty n00b


Joined: 29 Sep 2008
Posts: 2

PostPosted: Mon Sep 29, 2008 3:06 pm    Post subject: Reply with quote

Celeb wrote:
No need for any expansion since it already supports it.
In fact, the code you posted should work perfectly.

Thank you for the answer.
I must have missed that in the manual...
Back to top
View user's profile Send private message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Tue Jan 20, 2009 6:31 pm    Post subject: Reply with quote

There are some simple rules to remember:

* $_SESSION becomes "session", small-case, with removed $_ part.
* This is true for other variables like get, post, cookie, ...
* index should be case sensitive (use as typed).
* For example: $smarty.session.logged_in is from $_SESSION['logged_in']
* Reservation is identified with $smarty.

Unfortunately, there are no ways to see errors for:
$smarty.non_existent.variable. Any idea to raise an error, without {if} comparison?[/list]
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 -> Feature Requests 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