Session / Auth problem: Only when request SiteController app()->user gets authenticated

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

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.

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.

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!

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.

Install:

Denwer (php 5.3.3, apache, mysql),

Project has structure like that:

framework //Yii

www // webroot

[indent]

assets

protected

index.php

[/indent]

Yeah.

To solve in config/main.php:




...

'components'=>array(

...

        'session' => array(

            'cookieParams' => array('path' => '/',),

        ),

...