Yii Framework Forum: Session management with separate entry scripts - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Session management with separate entry scripts Rate Topic: -----

#1 User is offline   gattu_marrudu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 07-May 11

Posted 01 June 2011 - 10:33 PM

Starting from the suggestions on http://www.yiiframew...nd-and-back-end I am developing a double-ended application with an entry script for the front-end part and another one for the back-end administration panel.
My problem is that frontend and backend logons are independent. If I log in e.g. as "admin" on my backend, the frontend still has me as a guest, and if I log in from the frontend e.g. as "editor", I am seen as editor on the frontend and admin on the backend. If I log off from either end, both users are logged off.
I am using two separate config files, where the backend inherits and sort of extends the frontend settings.
This is the dump result of Yii::app()->session->toArray():
array
(
    '502a9d486b12ee08fa689a7b194d74c1__id' => '2'
    '502a9d486b12ee08fa689a7b194d74c1__name' => 'editor'
    '502a9d486b12ee08fa689a7b194d74c1name' => 'editor'
    '502a9d486b12ee08fa689a7b194d74c1role' => 'editors'
    '502a9d486b12ee08fa689a7b194d74c1__states' => array
    (
        'name' => true
        'role' => true
    )
    'bf092e7b507e19e4039c4f5cb58b9bc7__id' => '1'
    'bf092e7b507e19e4039c4f5cb58b9bc7__name' => 'admin'
    'bf092e7b507e19e4039c4f5cb58b9bc7name' => 'admin'
    'bf092e7b507e19e4039c4f5cb58b9bc7role' => 'administrators'
    'bf092e7b507e19e4039c4f5cb58b9bc7__states' => array
    (
        'name' => true
        'role' => true
    )
)


Both sessions are saved on the same cookie, but the login data for each entry script are stored on separate values.
Is there a way to have both scripts use the same values and share login data?
Thanks
gm

EDIT: the two ends share the models folder and thus the LoginForm.php file, as well as the UserIdentity component which extends CUserIdentity.
0

#2 User is offline   phtamas 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 529
  • Joined: 26-February 11
  • Location:Mezőtúr, Hungary

Posted 02 June 2011 - 03:42 PM

CWebUser::$stateKeyPrefix is configurable:

'components' => array(
	'user' => array(
		'stateKeyPrefix' => '...set it to the same value for both backend and frontend ',
	),
),


0

#3 User is offline   gattu_marrudu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 07-May 11

Posted 02 June 2011 - 04:01 PM

That works! Thanks a lot. I kept looking for the answer in CUserIdentity and CHttpSession...
I will post my improvement suggestions to the above mentioned wiki article as soon as I finish testing.
Yii rocks!
gm
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users