I have a page that used to store a session and then I want to retrieve the value of those session in another page. But when I try to retrieve it, it return nothing.
The script something like this:
Page A(add session value)
Yii::app()->session[‘parent’] = ‘Example’;
And then I move to Page B by click a link in Page A,
Page B(retrieve the initiated session above)
echo Yii::app()->session[‘parent’];
In page B, script above return nothing. AFAIK, in PHP session it would available in whole system. Does Yii has a configuration to manage session it self so it would available in whole system? or something wrong based on my script?
Yii::app()->session should work as you expect, without any configuration. For debugging I recommend the following:
If your site has subdomains check if PageB is under the same subdomain as PageA. Session cookie may not be sent back by the browser if subdomain is different.
If you have any configuration for session component try to comment it out, and check if it works.
Try to use session_start() and $_SESSION array directly to make sure that nothing is wrong with your php (or browser) configuration.