View previous topic :: View next topic |
Author |
Message |
koejkje Smarty Rookie
Joined: 27 Nov 2003 Posts: 30 Location: Miami, Florida
|
Posted: Thu Aug 25, 2005 4:32 am Post subject: $smarty.session no display |
|
|
I work on the development team for Edit-X CMS and we are thinking about using the $smarty.session.var instead of assigning all the session vars directly however we are having some issues on various configurations getting the template variable to actually display. Is there a configuration setting that might be limiting the display of session variables in Smarty? Thanks in advance for any information you can provide. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Aug 25, 2005 3:27 pm Post subject: |
|
|
Assigning session vars directly will shorten up the template var names, as well as decouple the templates from your underlying data structure (a good thing.) However, using $smarty.session should work. What issues specifically? |
|
Back to top |
|
koejkje Smarty Rookie
Joined: 27 Nov 2003 Posts: 30 Location: Miami, Florida
|
Posted: Thu Aug 25, 2005 3:37 pm Post subject: |
|
|
The variables just do not show up on my local development machine. Everyone else's works fine so I was thinking it might be a config issue. I compared mine to those around the office and the only blaring differences were register globals and the server variable order which I tried with no luck. We need to know what would cause this to not show up before using this variable method. Do you see any overhead from assigning all of the session variables instead of accessing them through Smarty? I can tell you what various systems we are using and version numbers if you think it would help. We can not find anywhere this same issue or any type of configuration for this to display. I appreciate your prompt reply. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Aug 25, 2005 3:40 pm Post subject: |
|
|
take a look at the compiled smarty template, see what it is doing to display the session variable. Then try this syntax in a test script, see if the problem is in the session or something else. Also, dump your session vars in PHP:
print_r($_SESSION)
be sure the vars you are after are there. |
|
Back to top |
|
koejkje Smarty Rookie
Joined: 27 Nov 2003 Posts: 30 Location: Miami, Florida
|
Posted: Thu Aug 25, 2005 5:53 pm Post subject: |
|
|
The compiled template file has the following...
<?php echo $GLOBALS['HTTP_SESSION_VARS']['company_city']; ?>
So I echoed this in my PHP code and get the following...
_SESSION[company_city]: DENVER
GLOBALS[HTTP_SESSION_VARS][company_city]:
I checked my settings in php.ini and I have globals available. We are using GLOBALS all over the place.
Thoughts? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Aug 25, 2005 6:26 pm Post subject: |
|
|
What version of Smarty/PHP are you using? If they are both recent, the compiled template should look like:
<?php echo $_SESSION['company_city']; ?>
Make sure you have set (default):
$smarty->request_use_auto_globals = true; |
|
Back to top |
|
koejkje Smarty Rookie
Joined: 27 Nov 2003 Posts: 30 Location: Miami, Florida
|
Posted: Thu Aug 25, 2005 6:38 pm Post subject: |
|
|
After further investigation, thanks for pointing that out by the way, I determined this to be a configuration setting in my php.ini file. I had a default install of PHP5 which has the register_long_arrays off by default whereas in PHP4 the default is on. PHP is recommending this off and this is also a depreciated array. Is there a setting to switch from the old style arrays to the new $_SESSION array? We are using the latest version of Smarty. Here is the confi line of my php.ini file that was modified...
; Whether or not to register the old-style input arrays, HTTP_GET_VARS
; and friends. If you're not using them, it's recommended to turn them off,
; for performance reasons.
register_long_arrays = on
I would be interested to see what Smarty has in store regading this issue moving forward. |
|
Back to top |
|
koejkje Smarty Rookie
Joined: 27 Nov 2003 Posts: 30 Location: Miami, Florida
|
Posted: Thu Aug 25, 2005 7:16 pm Post subject: |
|
|
I had not seen your latest post as I was researching and compiling mine.
This new configuration setting is exactly what I was looking for. I turned register_long arrays off in the php.ini and added the $smarty->request_use_auto_globals = TRUE; to our config file and it worked like a charm. I guess we have been using Smarty so long we weren't privy to the latest setting so we will review that. Is there a page you recommend for viewing the latest config additions?
This may seem trivial however I am sure this thread will help others.
Thank you for your time and patience. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Aug 25, 2005 7:28 pm Post subject: |
|
|
request_use_auto_globals has been around for some time (years)
You might check the changelog for changes made version to version.
http://smarty.php.net/misc/NEWS |
|
Back to top |
|
|