Home > symfony > Single session for all sub domains

Single session for all sub domains

Hi,

When you are having sub domain in your site by default the php will create a session for each of the sub domain for a user. you can not access the session $value1 of subdomain1 in the subdomain2 session. because the sessions are different for each sub domain for the same user. To make only one session for all the sub domain you need to set the a cookie with a .domain.com value for the domain parameter.

<?php
setcookie("TestCookie", $value, time()+3600, "/~tmp/", ".youdomain.com");
?>

Symfony Code:

in your application /config/factories.yml file add the following lines


storage:
class: sfSessionStorage
param:
session_name: symfony
session_cookie_domain: .yourdomain.com

now the user will be having only one session for all the sub domains.

–Asif–

symfony

  1. No comments yet.
  1. No trackbacks yet.

Powered by Yahoo! Answers