I had to inherit from sfSessionStorage to make it work.. Also, I just couldn't get it to work with domain limitations in that Explorer seems to send the cookies of the main domain to all subdomains. So I had to use a subdomain-based session name Here is the code bit, at the end it came out pretty simple, but I used hours trying to get it to work with domain limiting the cookies
class mySessionStorage extends sfSessionStorage { /** * This override sets the exact (sub)domain for session cookie and then initializes this Storage instance. * * @param sfContext A sfContext instance * @param array An associative array of initialization parameters * * @return boolean true, if initialization completes successfully, otherwise false * * @throws <b>sfInitializationException</b> If an error occurs while initializing this Storage */ public function initialize($context, $parameters = null) { // $parameters['session_cookie_domain'] = $_SERVER['SERVER_NAME']; // This doesn't work $parameters['session_name'] = 'symfony_'.$_SERVER['SERVER_NAME']; // This works // initialize parent parent::initialize($context, $parameters); } }
in factories.yml file add a auto_start entry like this:
all:
storage:
param:
auto_start: false
$storage = sfContext::getInstance()->getStorage(); $storage->write('test', 1); //$_SESSION['test'] = 1;
storage:
class: sfSessionStorage
param:
session_name: symfony
session_cookie_domain: .example.com
$sessionName = sfContext::getInstance()->getStorage()->getParameter('sf_session_name')
logs
8091.7 KB