Sharing Sessions

Hi,

I am looking at sharing sessions between two Yii applications. For example I have a frontend website that connects to a backend site on a different server with different domain names. How do I share the sessions between each other?

Shouldn’t this work?


	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'class' => 'MyWebUser',

			'identityCookie' => array(

				'domain' => 'localhost',

			),

		),


		'session' => array(

			'savePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'temp',

			'cookieMode' => 'allow',

			'cookieParams'=> array(

				'path' => '/',

				'httpOnly' => false,

				'domain' => 'localhost',

			),

		),

And add this to MyWebUSer class?


class MyWebUser extends CWebUser

{

    public $identityCookie = array(

        'path' => '/',

        'domain' => 'localhost',

    );

Thanks!

Ratty

This isn’t really a Yii question but I think you’ll need to store sessions in a replicated MySQL database that both sites have access to read/write.

Excellent thanks, I got it figured out by just sharing the sessions via a database.

Thanks!