Créer un compte ou loggez-vous pour pouvoir ajouter, commenter et noter les snippets.

Navigation

Tags relatifs

my Symfony Plugins

Plugins demos


My bookmarks

Vous pouvez commenter/noter en utilisant le compte anonymous (mot de passe: anonymous)
You can comment/rate using the anonymous account (password: anonymous).

Snippets taggés : "domain" Snippets taggés : "domain"

[symfony 1.0] Utiliser la même session pour tout les sous-domaines - 333 view(s)

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);
  }
 
}
 
par COil le 2008-09-29, taggé : domain  server  session  storage  subdomain  symfony 
(1 commentaire)
Debug toolbar