Tuesday, March 30, 2010

Re: I can't get the value of session in controller

Use the Session Component,

put this code in every controller that need to access to the session
component

var $components = array('Session')

if you are going to use Session in your whole app then it would be a
good idea to place that line in app_controller.

Then, to use your session component in your controller you use like
this

$this->Session->write('myVar', 'value'); //writes a session var named
"myVar
$this->Session->read('myVar'); // reads the session var value

You should read the book though http://book.cakephp.org/view/173/Sessions

On 30 mar, 04:33, Rimoe <meiyo...@gmail.com> wrote:
> hi,
>
> everyone,
>
> I have set a session in aa.php
> (
> session_start();
> $_SESSION['aa'] = '12345';
> )
> I  can read the value in bb.php
> (
> session_start();
> echo $_SESSION['aa'] ;
> )
>
> but I can't read the value in any  aaas_controller.php.
> (
> echo $this->Session->read('aa');
> echo $_SESSION['aa'];
> )
> do anyone know why is it?
>
> Thank you very much
>
> rimoe

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.

No comments: