Message-ID: <1837081633.3504.1485853432675.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3503_1772508551.1485853432674" ------=_Part_3503_1772508551.1485853432674 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Session

Session

Sessions are handled by the Symfony2 framework, specifically API= and underlying session handlers provided by HTTP Fundation compo= nent[1][2], this is further enhanced in eZ Publish with support for Si= teAccess aware sessio= n cookie configuration.

Use of Memcached (or experimentally using PDO) as session handler is= a requirement in Cluster setup, for details see below, for an overview of = clustering feature see Clustering

Session handlers

In Symfony, session handler is configured using framework.session.= handler_id. Symfony can be configured to use custom handlers[2], or just fallback to= what is configured in PHP by setting it to null (~).

Default configuration

Prior to 5.4 / 2014.11

Before 5.4 eZ Publish uses default Framework Bundle configuration, which on Symfony 2.3 implies&= nbsp;Symfony's NativeFileSession= Handler[3] (session.handler.native_file service). Th= is handler forces PHP's builtin "files" session save handler, and spec= ifically configures it to use sessi= on.save_path set to ezp= ublish/sessions by default (= ezpublish/cache/<env>/sessions before 5.3).

Default config.yml session configuration in 5.3 / 2014.03
=20
framework:
    session:
        save_path: "%kernel.root_dir%/sessions"
        # The session name defined here will be overridden by the one defin=
ed in your ezpublish.yml, for your SiteAccess.
        # Default session name is "eZSESSID{siteaccess_hash}" (unique sessi=
on name per SiteAccess).
        # See ezpublish.yml.example for an example on how to configure this=
.
=20

Session Garbage collection on Debian & Ubuntu

Debian based Linux distros disables= session.gc_pro= bability by default and uses cronjob instead to clear sessions files. A= s we use custom save_path for sessions here that would normally be a proble= m, however default Symfony configuration makes sure to re enable this in framework.session.gc_probability so with default Symfony and PHP= settings it should garbage collecting sessions files roughly every 100th t= ime on average (1% probability by default).

As of 5.4 / 2014.11

Uses same default configuration as recent versions of Symfony standard d= istribution, this makes sure you can configure sessions purely in php by de= fault, and allows Debian/Ubuntu session file cleanup cronjob to work as int= ended.

Default config.yml session configuration as of 5.4 / 2014.11
=20
framework:
    session:
        # handler_id set to null will use default session handler from php.=
ini
        handler_id:  ~
=20

Recommendations for pr= oduction setup

Single server setup

For single server, default handler should be preferred.

Cluster setup

For Cluster setup we need to con= figure Sessions to use a backend that is shared between web servers, and su= pports locking. Only options out of the box supporting this in Symfony is n= ative PHP memcached session save handler provided by php-memcached&n= bsp;extension, and Symfony session handler for PDO (database).

Storing ses= sions in Memcached using php-memcached

For setting up eZ Publish using this memcached you'll need to configure = the session save handler settings in php.ini as documented here, optionally tweak php= -memcached session settings, and use default configuration as of eZ Pub= lish 5.4 / 2014.11 documented above.

Alternative= storing sessions in database using PDO

While not currently our recommendation from performance perspective, for= setups where Database is preferred for storing Sessions, you may use Symfo= ny's PdoSessionHandler.
Below is an configuration example for eZ Publish= , but please refer to documented in Symfony Cookbook documentation for full document= ation.

=20
framework:
    session:
        # ...
        handler_id: session.handler.pdo

parameters:
    pdo.db_options:
        db_table:    session
        db_id_col:   session_id
        db_data_col: session_value
        db_time_col: session_time

services:
    pdo:
        class: PDO
        arguments:
            dsn:      "mysql:dbname=3D<mysql_database>"
            user:     <mysql_user>
            password: <mysql_password>

    session.handler.pdo:
        class:     Symfony\Component\HttpFoundation\Session\Storage\Handler=
\PdoSessionHandler
        arguments: ["@pdo", "%pdo.db_options%"]
=20

Further Symfony references

  1. Cookbook Session recipes (symfony.= com)
  2.  HTTP Fundation Com= ponent documentation (symfony.com)
  3. Source code of NativeFileSessio= nHandler (github.com)
  4. Cookbook Confi= guration recipe for setting-up PdoSessionHandler (symfony.com), aka&nbs= p;session.handler.pdo service

 

 

 

 

------=_Part_3503_1772508551.1485853432674--