@Jamie,

Its not wrong , its just not best practice and fall out of palce for
MVC design pattern i guess.




On Jan 26, 3:45 am, Jamie <jamie....@gmail.com> wrote:
> You don't need to import a component, especially since components are
> for controllers. You can just do this in your Cart model:
>
> public $session = null;
>
> function __construct($id = false, $table = null, $ds = null) {
>         parent::__construct($id, $table, $ds);
>         App::import('Core', 'CakeSession');
>         $this->session = new CakeSession();
>
> }
>
> All the SessionComponent does is provide a controller-level wrapper
> for the CakeSession class. I don't see anything wrong with importing
> CakeSession itself right into your model.
>
> You can still do all of the regular session functions:
>
> $this->session->read
> $this->session->delete
> $this->session->write
>
> etc.
>
> - Jamie
>
> On Jan 20, 12:40 am, the_guru <l.rajibah...@gmail.com> wrote:
>
> > Hello Every body i am now using Session component on my Cart model
>
> > I have Cart Model which does not extends from AppModel
>
> > Now here is the code that i am using to access Session properties
>
> > class Cart
> > {
> >         public $Session = null;
>
> >         public function __construct(){
> >                 App::import('Component', 'SessionComponent');
> >                 $this->Session = new SessionComponent;
> >         }
>
> >         public function add($id){
>
> >         }
>
> >         public function remove($id)
> >         {
>
> >         }
>
> > }
>
> > ?>

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to