ngecoding.com logo

PHP Session Across Subdomains

//if(youLikeIt || itHelpsYou)clickShare();

By default, PHP not allowed to create Session across subdomains. For example, Session that you create in a.example.com will not readable in b.example.com, vice versa.

The code below will allow Session across subdomains.

//add this line before session_start()
ini_set('session.cookie_domain', '.example.com' );
session_start();

$_SESSION['test']="1";
//$_SESSION['test'] will readable in every subdomains.

Congratulate smiley

//if(youLikeIt || itHelpsYou)clickShare();
//Advertisements
Take a Break //non-technical articles
Hot Topics //most used tags
Email Subscriptions //We won't spam you. Honest!

Enter your email address:

Delivered by FeedBurner