[support] Session variable and cache

Bert Van Kets mailing at vankets.com
Thu Apr 19 20:45:36 UTC 2012


I'm sending the answer here for completeness.
Apparently the session variables are persistent in the database and 
that's why the animation was only shown once.
The solution is to use a module or theme preprocess function and pass 
the result of that to the page template. A timestamp variable can keep 
track if the animation has played or not.

Bert

On 18/04/2012 12:41, Bert Van Kets wrote:
> I just did some tests and setting the cache lifetime to 1 minute does
> not have any effect.
> Still stuck. :-(
>
> Bert
>
> On 18/04/2012 10:25, Bert Van Kets wrote:
>> Gordon,
>>
>> it does look like the Splash module could do what I need if I were using
>> D6. :-/
>>
>> In the mean time I set the cache lifetime to 1 minute. As this is a
>> super small site with hardly any visitors (it's a SOHO company web
>> presence type of site) caching is hardly necessary.
>>
>> Bert
>>
>> On 18/04/2012 10:17, Gordon Heydon wrote:
>>> Hi,
>>>
>>> Take a look at the splash module http://drupal.org/project/splash it may provide a solution for you.
>>>
>>> Gordon.
>>>
>>> On 18/04/2012, at 5:53 PM, Bert Van Kets wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have a D7 website that needs to show an animation when the user enters
>>>> the site, but not for as long as the user stays on the site.
>>>> I wanted to use a session variable for this, but it seems there are many
>>>> times the animation is not triggered. I assume this is due to caching of
>>>> the page. How can I overcome this? Is there a cache save session
>>>> variable or an alternative method used in situations like mine.
>>>>
>>>> At the start of the animation part I have the code
>>>> <?php
>>>> if(! isset($_SESSION['showAnimation'])):
>>>> ?>
>>>>
>>>> at the end of the part I have
>>>> <?php
>>>> endif;
>>>> $_SESSION['showAnimation']=2;
>>>> ?>
>>>>
>>>> So when the user first visits the site, the variable is not found and
>>>> the animation is show. After the animation the session variable is set
>>>> and the animation is not shown any more. That last version is cached and
>>>> the animation is not shown, even for the next user who visits the site.
>>>>
>>>> Thanks for any help.
>>>>
>>>> Bert
>>>>
>>>>
>>>> -- 
>>>> [ Drupal support list | http://lists.drupal.org/ ]



More information about the support mailing list