This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/includes/kohana/system/classes/Kohana/Session/Native.php

108 lines
1.8 KiB
PHP
Raw Normal View History

2012-11-09 12:18:50 +00:00
<?php defined('SYSPATH') OR die('No direct script access.');
2010-08-21 04:43:03 +00:00
/**
* Native PHP session class.
*
* @package Kohana
* @category Session
* @author Kohana Team
2012-11-09 12:18:50 +00:00
* @copyright (c) 2008-2012 Kohana Team
2011-05-13 06:00:25 +00:00
* @license http://kohanaframework.org/license
2010-08-21 04:43:03 +00:00
*/
class Kohana_Session_Native extends Session {
2011-05-13 06:00:25 +00:00
/**
* @return string
*/
2010-08-21 04:43:03 +00:00
public function id()
{
return session_id();
}
2011-05-13 06:00:25 +00:00
/**
* @param string $id session id
* @return null
*/
2010-08-21 04:43:03 +00:00
protected function _read($id = NULL)
{
// Sync up the session cookie with Cookie parameters
session_set_cookie_params($this->_lifetime, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httponly);
// Do not allow PHP to send Cache-Control headers
session_cache_limiter(FALSE);
// Set the session cookie name
session_name($this->_name);
if ($id)
{
// Set the session id
session_id($id);
}
// Start the session
session_start();
// Use the $_SESSION global for storing data
$this->_data =& $_SESSION;
return NULL;
}
2011-05-13 06:00:25 +00:00
/**
* @return string
*/
2010-08-21 04:43:03 +00:00
protected function _regenerate()
{
// Regenerate the session id
session_regenerate_id();
return session_id();
}
2011-05-13 06:00:25 +00:00
/**
* @return bool
*/
2010-08-21 04:43:03 +00:00
protected function _write()
{
// Write and close the session
session_write_close();
return TRUE;
}
2012-11-09 12:18:50 +00:00
/**
* @return bool
*/
protected function _restart()
{
// Fire up a new session
$status = session_start();
// Use the $_SESSION global for storing data
$this->_data =& $_SESSION;
return $status;
}
2011-05-13 06:00:25 +00:00
/**
* @return bool
*/
2010-08-21 04:43:03 +00:00
protected function _destroy()
{
// Destroy the current session
session_destroy();
2011-05-13 06:00:25 +00:00
// Did destruction work?
$status = ! session_id();
if ($status)
{
// Make sure the session cannot be restarted
Cookie::delete($this->_name);
}
return $status;
2010-08-21 04:43:03 +00:00
}
} // End Session_Native