Forums / Developer / please, very urgent:how to store session variables?

please, very urgent:how to store session variables?

Author Message

Alessandro Cipriani

Tuesday 09 March 2004 2:30:16 am

hi all
i've this GREAT problem due to my need to store a variable in session and to the lack of documentation (and forum answers) about it.
i've seen also some documentation here:
http://doc.ez.no/class_ref/doc/view/ezsession5a62.html?PrintableVersion=enabled#999999
but i don't understand how to use the example in it!!!
i even tried to insert the code into the index.php code, but i get only a fatal error...

i said: if there is the possibility to store variable values in session, WHY there isn't enough documentation about it????

best regards
alessandro

Bård Farstad

Tuesday 09 March 2004 2:48:57 am

You can set a session variable by doing:
$http =& eZHTTPTool::instance();
$http->setSessionVariable( "MyVar", "MyValue" );

You can read the session variable by doing:
if ( $http->hasSessionVariable( "MyVar" ) )
$myVar = $http->sessionVariable( "MyVar" );

This is PHP code, you cannot set session variables in templates.

--bård

Documentation: http://ez.no/doc

Alessandro Cipriani

Tuesday 09 March 2004 2:53:04 am

thanx bard?
just other 2 questions: where should i place this code? into the index.php file?
there is the possibility to retrieve a timestamp (or session id) into this code and store it in a session variable?

best regards
alessandro

Alessandro Cipriani

Tuesday 09 March 2004 6:24:09 am

bard
i can't get the session variable into the template since the language is php right?
so, can you explain me where should i write the code that retrieves the value and how to pass it to the template?

best regards
alessandro

eZ debug

Timing: Jan 18 2025 22:24:56
Script start
Timing: Jan 18 2025 22:24:56
Module start 'content'
Timing: Jan 18 2025 22:24:57
Module end 'content'
Timing: Jan 18 2025 22:24:57
Script end

Main resources:

Total runtime0.8717 sec
Peak memory usage4,096.0000 KB
Database Queries61

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0099 587.8594180.8125
Module start 'content' 0.00990.8383 768.6719565.2969
Module end 'content' 0.84820.0234 1,333.968846.0703
Script end 0.8716  1,380.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3701140.0002
Check MTime0.00140.1596140.0001
Mysql Total
Database connection0.00180.209710.0018
Mysqli_queries0.795291.2266610.0130
Looping result0.00060.0666590.0000
Template Total0.832195.520.4160
Template load0.00210.237120.0010
Template processing0.830095.217720.4150
Template load and register function0.00010.013610.0001
states
state_id_array0.00130.148610.0013
state_identifier_array0.00200.225220.0010
Override
Cache load0.00180.2010370.0000
Sytem overhead
Fetch class attribute can translate value0.00160.182820.0008
Fetch class attribute name0.00150.175360.0003
XML
Image XML parsing0.00140.159220.0007
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.01491.7112250.0006
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs