0

I have a kohana installation, version 3.x, and I'm already using 'native' driver.

I want set a $_SESSION variable in kohana controllers, and be able to use this in an external.php file, that is outside the kohana installation.

How can I do this without screw up the session that kohana is using?

Thanks. Regards

hakre
  • 193,403
  • 52
  • 435
  • 836

1 Answers1

0

I'm looking at the code in 3.2, and you pretty much should be able to get the data just by calling it like normal.

Session::instance()->set('foo', 'bar');

// Should return 'bar'
echo $_SESSION['foo'];

Kohana's native driver initializes the session by setting Session::$_data as a reference to $_SESSION. The only thing that might make this weird is if it uses __toString() somehow that I'm not seeing, where it would then serialize the data. AFAIK, it doesn't, but it wouldn't be the first time I've been wrong. The only thing you might want to check is the cookie name being used by the session in Kohana and make sure you are using that to get the correct session_id() for the external code.

My question to you is why and how are you accessing that external php file? You may be able to just pull it into Kohana and use it along with Kohana code if you wanted.