[themes] session variable in page--front.tpl.php
Bert Van Kets
mailing at vankets.com
Thu Apr 19 13:55:32 UTC 2012
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 at vankets.com <mailto:mailing at vankets.com>>
> Subject: [themes] session variable in page--front.tpl.php
> To: themes at drupal.org <mailto:themes at drupal.org>
> Message-ID: <4F8FBAC3.8000903 at vankets.com
> <mailto:4F8FBAC3.8000903 at 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 at drupal.org <mailto:themes at drupal.org>
> http://lists.drupal.org/mailman/listinfo/themes
>
>
> End of themes Digest, Vol 61, Issue 1
> *************************************
>
>
>
>
> --
> Ken Rickard
> agentrickard at gmail.com <mailto:agentrickard at gmail.com>
> http://ken.therickards.com
>
>
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/themes/attachments/20120419/975a8d99/attachment.html
More information about the themes
mailing list