I am using cakePHP 1.26.
In a .ctp file, I have a few like of codes like this:
$sess = $this->Session->check('user');
if($sess){
// do soemthing
}
else{
// do soemthing then
}
But I got this error then:
Fatal error: Call to a member function
check() on a non-object in
/home/vol12/mysite.com/htdocs/app/views/layouts/testing1.ctp
on line 10
Can I use the Check method in a .ctp file to check if a session exists?
There is a session component for use in controllers, of course, that is referenced as
$this->Session. What you’re looking for, I think is the session helper that is available to views. This is referenced simply as$session, IIRC. I wanted to verify that (it’s been a while since I had to use it), but can’t find it in the docs at the moment. What I think you want is: