Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Isguest() , Cookie , Subdomain.

$
0
0
Hi devs,

I have a problem which is similar to this one => http://www.yiiframework.com/forum/index.php/topic/15104-changing-isguest-value/

I have a domain which doesn't uses YII frame work and trying to creating a subdomain based on YII. Now in my domain, I determine if the user is logged in based on $Session['email'] and $Session['__id']. If the session email and id exist, then the user is logged in. I found out that Yii's Yii::app->user->isGuest checks for the variable '__id' and test if it's === null. http://www.yiiframework.com/doc/api/1.1/CWebUser#getIsGuest-detail

Problem: When a user login from domain then navigate to the subdomain, Yii::app->user->isGuest returns true, even when $Session['__id'] = {aString}, and all other session variable is accessible .

Expected output: User should not be guest when going into subdomain.

Code:
config/main.php
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			
		),
		// session configuration
		'session' => array(
            'autoStart' => true,
			'cookieMode' => 'allow',
			'cookieParams' => array(
				'domain' => '.localhost.com',
			),



domain's login.php. code that runs when user login.

	session_start();//start session here 
.  .  .
			$_SESSION['email'] = $email;
			$_SESSION['__id'] = "logged in";
.  .  .


current output in yii subdomain:
Yii::app()->user->isGuest = 1
Yii::app()->session['email']= {the email }
Yii::app()->session['__id']= "logged in"

Thanks for your help. ^^

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>