CakePHP Session-> valid()始终返回false

I have a CakePHP version 2.3 web application, and have run into a confusing Session issue. In the following code, $session_valid is always 'false', even though I can read the 'netid' value just fine.

$this->Session->write( 'netid', $netid );

$session_valid = $this->Session->valid();

What am I missing here?

I think the function you are looking for is

$this->Session->check('netid')

It checks if the session variable is set