idrozd
(Terracote)
March 17, 2011, 8:03am
1
Consider this:
Using gii-provided actionLogin of the SiteController i log in.
After that, when i’m accessing SiteController’s actions, everything is going fine, user is authenticated and all that.
But when i request any other controller, $_SESSION for some reason only contains __returnUrl , no __id or __name 8(((((((((
I’m angry, frustrated and want to smash hundred cute kittens with a hammer.
And then burn them with flamethrower.
So. Any ideas?
Where could one find flamethrower at 11pm?
UPDATE : SOLVED
zaccaria
(Matteo Falsitta)
March 17, 2011, 8:14am
2
Don’t care about what is in session.
Use only Yii methods: check if Yii::app()->user->isGuest is false, it means that the user is logged in.
Check if Yii::app()->user->id contains the id of the user, it means that you are logged with the right user.
If you use a framework, use the instrument of the framework. I have been using Yii since it exists, and I have never felt the need of check what ther is in $_SESSION.
idrozd
(Terracote)
March 17, 2011, 8:26am
3
2zaccaria
Yeah… In fact, that’s what i did. And since it didn’t help, i’ve drilled to the very bottom of yii ))
getIsGuest
is
(getState(’__id’) === null) ,
getState(’__id’ )
is
$_SESSION[$someRandomString.’__id’]
Anyway, still no thoughts on flamethrower? I really need this.
idrozd
(Terracote)
March 17, 2011, 9:27am
4
Oh.
For some reason Yii sets two PHPSESSID’s: one for /site
and one for /
So… i just have to spend couple more hours trying to figure out why.
Hurt kittens shall be not.
Hail Satan!
zaccaria
(Matteo Falsitta)
March 17, 2011, 9:44am
5
That is really strange.
Did you use some very particular implementation or folder structure (or maybe 2 indexes)?
I have never heard about such a problem.
idrozd
(Terracote)
March 17, 2011, 9:52am
6
Install:
Denwer (php 5.3.3, apache, mysql),
Project has structure like that:
framework //Yii
www // webroot
[indent]
assets
…
protected
…
index.php
[/indent]
idrozd
(Terracote)
March 17, 2011, 10:54am
7
Yeah.
To solve in config/main.php:
...
'components'=>array(
...
'session' => array(
'cookieParams' => array('path' => '/',),
),
...