use of sessions in cakephp

can anyone give me an example on how to create Sessions and write data to it. I've seen syntax on how to write data to a session using write command. But how to create a session and retrieve the values in it.

In my application, I have two data, form_id and user_id that needs to be used in all the page requests. So how do I save it as a session variable and use it across the application?


function register()
	//echo "session".$this->Session->read('User.UserId');
    if (!$this->User->validates())
    $this->Flash('Please enter valid inputs','/forms' );

$this->Flash('User account created','/forms/homepage/'.$userId);            


How to use the session variable 'User.UserId' instead of $userId in $this->Flash('User account created','/forms/homepage/'.$userId);

And can I use this variable in all my view files,because in all the page requests I also pass the userId?


I have 2 controllers,user and form. I write the userid to a session variable in the users*_controller. I have a view file called homepage.ctp,whose action is in the forms_controller.* Now how can I use the session variable defined in the users_controller in the homepage? Sorry if I am asking silly questions. I went through the cakebook,but my doubts weren't cleared. I'm also trying trial and error method of coding,so please help me.


I have a session variable 'uid' which is the user id in the home page action of a controller.


I need the same variable in the design action method of the same controller.
When I give

            echo "uid: ".$uid;

the value is not echoed.

Can't I use the session variable in the same controller?