Prabu
Prabu

Reputation: 2298

cakephp Session->write problem in linux

I have problem with cakephp's Session->write method.

If I set a value like $_SESSION['..'] i'm able to read it back. But if I use the write method it's not working.

My problem is same as here: http://www.nabble.com/Session-problem-td16684956.html

The same code was working in windows but it's not working after I moved to linux.

Any permission problem would be the reason? (but i have given rw permission fully for the cake app directory).

code sample: in the link: http://www.nabble.com/Session-problem-td16684956.html

cake version: 1.2.3.8166

Upvotes: 0

Views: 6666

Answers (3)

foxns7
foxns7

Reputation: 518

You should also try to use Cache::read and Cache::write

if (($session = Cache::read('session')) === false) 
{
   $session = 'some values';
   Cache::write('session', $session);
} 

Firstly, it will try to initialize Cache::read. If it returns false, Cache::write will take part to store the values in sessions.

Upvotes: 0

Travis Leleu
Travis Leleu

Reputation: 4230

Prabu,

While I suspect the Configure::write() call will sometimes correctly set the session information (at least it looks like it might work), the Cake convention (aka the CakeWay) is to use the Session helper. I believe it is included by default in all Cake controllers; if not, you can always declare your controller as such:

class UsersController extends AppController {
 ...
 var $helpers = array( 'Session', ... )
 ...
}

Then, when you want to write info to the session, just call:

$this->Session->write( 'checkAgent', false );

To read back values, use:

$this->Session->read( 'checkAgent');

For more information on the Session helper, check out the CakeBook @ http://book.cakephp.org/view/484/Session

Upvotes: -1

dr Hannibal Lecter
dr Hannibal Lecter

Reputation: 6721

Some steps to ensure it's not you:

  • clear the cache in your /app/tmp
  • check and recheck that your /app/tmp is world-writable recursively (that means drwxrwxrwx for all folders inside)
  • use Firebug to check your session cookie, maybe something has gone wrong with it

Last but not least, try to move your session persistence to your database (see: Session.save), just to test things out that way, you never know what you'll find.

Hopefully you'll find something if you try all these.

Upvotes: 2

Related Questions