Add my own variable in session

Author Message

Paul Etienney

Wednesday 25 February 2009 3:08:25 am

Hi,

I would like to build a tracker on specific class.

I would like to know all the objects of the "software" class the visitor have seen.

I can't find a way to add my own variable in the session. Do you know a good solution ?

-- Good websites creation --
My site : http://www.pauletienney.com
Twitter : http://www.twitter.com/p_etienney

Paul Etienney

Wednesday 04 March 2009 8:20:28 am

Any idea ?

-- Good websites creation --
My site : http://www.pauletienney.com
Twitter : http://www.twitter.com/p_etienney

Piotrek Karaƛ

Wednesday 04 March 2009 9:31:30 pm

Create a temple operator called for example tracksoftware() that would take two parameters:
- function name: 'set' or 'get'
- $node_id (or $object_id, up to your needs).

The core code for the operator should look something like:

$http = eZHTTPTool::instance(); // if it is not there already
$trackSoftwareSessionVariable = 'PaulTrackSoftware';
$operatorValue = false;
if( $function == 'get' )
{
    if( $http->hasSessionVariable( $trackSoftwareSessionVariable ) )
    {
        $operatorValue = $http->sessionVariable( $trackSoftwareSessionVariable );
    }
}
if( $function == 'set' )
{
    $nodeIDArray = array();
    if( $http->hasSessionVariable( $trackSoftwareSessionVariable ) )
    {
        $nodeIDArray = $http->sessionVariable( $trackSoftwareSessionVariable );
    }
    if( !in_array( $nodeID, $nodeIDArray ) )
    {
        $nodeIDArray[] = $nodeID;
    }
    $http->setSessionVariable( $trackSoftwareSessionVariable, $nodeIDArray );
    $operatorValue = true;
}

This may be buggy, but should get you pretty close to where I think you want to get...

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 08:16:54
Script start
Timing: Jan 31 2025 08:16:54
Module start 'layout'
Timing: Jan 31 2025 08:16:54
Module start 'content'
Timing: Jan 31 2025 08:16:54
Module end 'content'
Timing: Jan 31 2025 08:16:54
Script end

Main resources:

Total runtime0.0158 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.1328151.2109
Module start 'layout' 0.00480.0034 739.343836.6641
Module start 'content' 0.00820.0059 776.007894.2656
Module end 'content' 0.01420.0016 870.273433.9922
Script end 0.0157  904.2656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002213.8877140.0002
Check MTime0.00106.5032140.0001
Mysql Total
Database connection0.00074.603010.0007
Mysqli_queries0.003320.892830.0011
Looping result0.00000.107310.0000
Template Total0.00116.810.0011
Template load0.00085.281810.0008
Template processing0.00021.457210.0002
Override
Cache load0.00053.322710.0005
General
dbfile0.001911.859180.0002
String conversion0.00000.030240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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