Drupal uses persistent session storage -- in the database -- which is what lets your login persist. Session data is stored too.
The simple way around this is to also store a session expiration time for your display. If that time has passed, clear both session variables and reset them.
From a security and best practice standpoint, please don't put this logic
in a tpl file. It belongs in a module or theme preprocess function. Set $show_animation as part of the variables you pass to the template.
----------------------------------------------------------------------
Message: 1 Date: Thu, 19 Apr 2012 09:12:03 +0200 From: Bert Van Kets mailing@vankets.com Subject: [themes] session variable in page--front.tpl.php To: themes@drupal.org Message-ID: 4F8FBAC3.8000903@vankets.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi,
I'm using D7 and need a way to show an animation only once when a visitors comes to the site. I am using a session variable in my page--front.tpl.php file and if it's not set, it shows the animation. Code snips below. For some reason though once the animation is shown on a PC, it is not shown again at all. Even when the browser is closed and I wait a day. When I log into the site and log out, the animation is shown fine. I assume the session is reset to clear all the authorization data and that's why the animation is shown.
I thought it was the caching that kept the animation from showing, but even setting the cache lifetime to 1 minute does not solve the problem. There must be something else going on. Does anybody have an idea on what may be blocking the animation?
Is there an alternative way to get this conditional presentation going? I have read cookies are not recommended.
Thanks for any help.
Bert
Code snip:
<?php if(! isset($_SESSION['showAnimation'])): ?>
<javascript block containing the animation. Everything is in javascript so the animation does not block the site if JavaScript is not supported./>
<?php endif; $_SESSION['showAnimation']=1; ?>
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
End of themes Digest, Vol 61, Issue 1
Thanks for the pointer. I'll do some research and see how I should implement this. It least I know the cause now.
Bert
On 19/04/2012 15:31, Ken Rickard wrote:
Drupal uses persistent session storage -- in the database -- which is what lets your login persist. Session data is stored too.
The simple way around this is to also store a session expiration time for your display. If that time has passed, clear both session variables and reset them.
From a security and best practice standpoint, please don't put this logic in a tpl file. It belongs in a module or theme preprocess function. Set $show_animation as part of the variables you pass to the template.
Message: 1 Date: Thu, 19 Apr 2012 09:12:03 +0200 From: Bert Van Kets <mailing@vankets.com <mailto:mailing@vankets.com>> Subject: [themes] session variable in page--front.tpl.php To: themes@drupal.org <mailto:themes@drupal.org> Message-ID: <4F8FBAC3.8000903@vankets.com <mailto:4F8FBAC3.8000903@vankets.com>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi, I'm using D7 and need a way to show an animation only once when a visitors comes to the site. I am using a session variable in my page--front.tpl.php file and if it's not set, it shows the animation. Code snips below. For some reason though once the animation is shown on a PC, it is not shown again at all. Even when the browser is closed and I wait a day. When I log into the site and log out, the animation is shown fine. I assume the session is reset to clear all the authorization data and that's why the animation is shown. I thought it was the caching that kept the animation from showing, but even setting the cache lifetime to 1 minute does not solve the problem. There must be something else going on. Does anybody have an idea on what may be blocking the animation? Is there an alternative way to get this conditional presentation going? I have read cookies are not recommended. Thanks for any help. Bert Code snip: <?php if(! isset($_SESSION['showAnimation'])): ?> <javascript block containing the animation. Everything is in javascript so the animation does not block the site if JavaScript is not supported./> <?php endif; $_SESSION['showAnimation']=1; ?> ------------------------------ _______________________________________________ themes mailing list themes@drupal.org <mailto:themes@drupal.org> http://lists.drupal.org/mailman/listinfo/themes End of themes Digest, Vol 61, Issue 1 *************************************-- Ken Rickard agentrickard@gmail.com mailto:agentrickard@gmail.com http://ken.therickards.com
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes