Hello again,

I have tried your suggestion but it still does not read the value from
the session. I will paste my entire controller code here.  Thanks
again:

<?php

class EventsController extends AppController
{
        var $name = 'Events';
        var $layout = 'layout1';
        var $components = array('Session');

        function index()
        {
                $events = $this->paginate();

                if (isset($this->params['requested'])) {
                        return $events;
                }

                $this->set('events', $events);
        }

        function view($id)
        {
                $events = $this->Event->User->findById($id);
                $this->set('events', $events);
        }

        function add()
        {
                if (!empty($this->data)) {

                        $this->data += array('User' => array('user_id' => 
$this->Session-
>read('User.user_id')));

                        if ($this->Event->save($this->data)) {

                                $this->Session->setFlash("A new event has been 
added");
                                $this->redirect('/events', null, true);
                        }
                }
        }
}

?>





On Mar 22, 12:44 am, mscdex <msc...@gmail.com> wrote:
> On Mar 21, 11:10 pm,cpeele<chris.peel...@gmail.com> wrote:
>
> > Am I supposed to set something up in order to use $this->Session in my
> > controller?
>
> At the top of your controller, you should only have to ensure your
> $components array attribute includes "Session." For example:
>
> var $components = array('Session');
>
> Then use:
>
> $this->Session->write('User.user_id', $userID);
>
> to write the session variable (replace $userID with the correct user
> ID), and:
>
> $current_userid = $this->Session->read('User.user_id');
>
> to read the current user ID.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to