I'm trying to set it up so if you log in to my website the session carries over to all sub-domains of my website. For example, if you go to domain.com and log in, then go to sub.domain.com, you'll already be logged in at sub.domain.com.

To my understanding, you would want to use ini\_set('session.cookie\_domain','.domain.com') and then session\_start(), then set your session variables, but this isn't working.

Example of what I'm doing:

Code for domain.com:

```
<?php
 ini_set('session.cookie_domain','.domain.com');
 session_start();
 $_SESSION['variable'] = 1;
?>

```

Code for sub.domain.com:

```
<?php
 session_start();
 echo $_SESSION['variable'];
?>

```

But $\_SESSION['variable'] isn't set.

I've also tried using ini\_set() in the sub.domain.com code, but it made no difference. I've verified that setting session.cookie\_domain is working by using ini\_get().

What am I doing wrong? Thanks!