Forums / Developer / Problem with session variable !

Problem with session variable !

Author Message

Fabien Garnier

Tuesday 26 August 2008 8:51:49 am

Hi everybody !

I try to use session variable in eZ.

I do this :
In my extension, in testview.php file, i have this code :

$tab = renvoiTab(); //return an array from a web service
$http = eZHTTPTool::instance();

if ($http->hasSessionVariable("stuff")) {
echo "session existante";
}
else {$http->setSessionVariable( 'stuff', $tab );}

$var = $http->sessionVariable("stuff");
$tpl->setVariable('result',$var);

and in my template (testview.tpl), i do this :

<table>
        <tr>
         <th align=center>Nom</th>
         <th align=center>Modele</th>
         <th align=center>Nombre de Place</th>
        </tr>


{foreach $result as $v}

        <tr>
         <td align=center>{$v.Nom}</td>
         <td align=center>{$v.Modele}</td>
         <td align=center>{$v.NbPlace}</td>
        </tr>

{/foreach}

</table>

and my session variable "stuff" never changes (while my web service result changes) even if i close the window or logout.

Do i use session variable correctly ?
How to destroy a session in ez ?

Best regards

FG

Pascal Specht

Tuesday 26 August 2008 9:00:51 am

Hi Fabien,

I'm not sure about this, but could it be that you're victim of the cache mechanism? Does your code work if you disable caching?

</Pascal>

Fabien Garnier

Tuesday 26 August 2008 11:39:48 pm

I have these lines in my "site.ini.append.php" since the beginning :

[OverrideSettings]
Cache=disabled

Do you have another idea ?
I think my problem is that I don't know how to close a session but i'm not sure...

Thank you for your help.

FG

eZ debug

Timing: Jan 20 2025 10:48:51
Script start
Timing: Jan 20 2025 10:48:51
Module start 'content'
Timing: Jan 20 2025 10:48:51
Module end 'content'
Timing: Jan 20 2025 10:48:51
Script end

Main resources:

Total runtime0.0231 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.9531180.8359
Module start 'content' 0.00680.0071 769.789193.9922
Module end 'content' 0.01400.0090 863.781370.7031
Script end 0.0230  934.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002410.2597120.0002
Check MTime0.00104.5367120.0001
Mysql Total
Database connection0.00083.512510.0008
Mysqli_queries0.003213.644140.0008
Looping result0.00000.072320.0000
Template Total0.008637.410.0086
Template load0.00083.252310.0008
Template processing0.007934.102510.0079
Override
Cache load0.00052.325110.0005
General
dbfile0.006226.7844100.0006
String conversion0.00000.029930.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs