CakeSession.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <?php
  2. /**
  3. * Session class for Cake.
  4. *
  5. * Cake abstracts the handling of sessions.
  6. * There are several convenient methods to access session information.
  7. * This class is the implementation of those methods.
  8. * They are mostly used by the Session Component.
  9. *
  10. * PHP 5
  11. *
  12. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  13. * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. *
  15. * Licensed under The MIT License
  16. * Redistributions of files must retain the above copyright notice.
  17. *
  18. * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  19. * @link http://cakephp.org CakePHP(tm) Project
  20. * @package cake
  21. * @subpackage cake.cake.libs
  22. * @since CakePHP(tm) v .0.10.0.1222
  23. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  24. */
  25. App::uses('Set', 'Utility');
  26. /**
  27. * Session class for Cake.
  28. *
  29. * Cake abstracts the handling of sessions. There are several convenient methods to access session information.
  30. * This class is the implementation of those methods. They are mostly used by the Session Component.
  31. *
  32. * @package cake
  33. * @subpackage cake.cake.libs
  34. */
  35. class CakeSession {
  36. /**
  37. * True if the Session is still valid
  38. *
  39. * @var boolean
  40. */
  41. public static $valid = false;
  42. /**
  43. * Error messages for this session
  44. *
  45. * @var array
  46. */
  47. public static $error = false;
  48. /**
  49. * User agent string
  50. *
  51. * @var string
  52. */
  53. protected static $_userAgent = '';
  54. /**
  55. * Path to where the session is active.
  56. *
  57. * @var string
  58. */
  59. public static $path = '/';
  60. /**
  61. * Error number of last occurred error
  62. *
  63. * @var integer
  64. */
  65. public static $lastError = null;
  66. /**
  67. * 'Security.level' setting, "high", "medium", or "low".
  68. *
  69. * @var string
  70. */
  71. public static $security = null;
  72. /**
  73. * Start time for this session.
  74. *
  75. * @var integer
  76. */
  77. public static $time = false;
  78. /**
  79. * Cookie lifetime
  80. *
  81. * @var integer
  82. */
  83. public static $cookieLifeTime;
  84. /**
  85. * Time when this session becomes invalid.
  86. *
  87. * @var integer
  88. */
  89. public static $sessionTime = false;
  90. /**
  91. * Keeps track of keys to watch for writes on
  92. *
  93. * @var array
  94. */
  95. public static $watchKeys = array();
  96. /**
  97. * Current Session id
  98. *
  99. * @var string
  100. */
  101. public static $id = null;
  102. /**
  103. * Hostname
  104. *
  105. * @var string
  106. */
  107. public static $host = null;
  108. /**
  109. * Session timeout multiplier factor
  110. *
  111. * @var integer
  112. */
  113. public static $timeout = null;
  114. /**
  115. * Number of requests that can occur during a session time without the session being renewed.
  116. * This feature is only used when `Session.harden` is set to true.
  117. *
  118. * @var integer
  119. * @see CakeSession::_checkValid()
  120. */
  121. public static $requestCountdown = 10;
  122. /**
  123. * Constructor.
  124. *
  125. * @param string $base The base path for the Session
  126. * @param boolean $start Should session be started right now
  127. */
  128. public static function init($base = null, $start = true) {
  129. self::$time = time();
  130. $checkAgent = Configure::read('Session.checkAgent');
  131. if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT') != null) {
  132. self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
  133. }
  134. if ($start === true) {
  135. self::_setPath($base);
  136. self::_setHost(env('HTTP_HOST'));
  137. }
  138. if (isset($_SESSION) || $start === true) {
  139. self::start();
  140. }
  141. }
  142. /**
  143. * Setup the Path variable
  144. *
  145. * @param string $base base path
  146. * @return void
  147. */
  148. protected static function _setPath($base = null) {
  149. if (empty($base)) {
  150. self::$path = '/';
  151. return;
  152. }
  153. if (strpos($base, 'index.php') !== false) {
  154. $base = str_replace('index.php', '', $base);
  155. }
  156. if (strpos($base, '?') !== false) {
  157. $base = str_replace('?', '', $base);
  158. }
  159. self::$path = $base;
  160. }
  161. /**
  162. * Set the host name
  163. *
  164. * @param string $host Hostname
  165. * @return void
  166. */
  167. protected static function _setHost($host) {
  168. self::$host = $host;
  169. if (strpos(self::$host, ':') !== false) {
  170. self::$host = substr(self::$host, 0, strpos(self::$host, ':'));
  171. }
  172. }
  173. /**
  174. * Starts the Session.
  175. *
  176. * @return boolean True if session was started
  177. */
  178. public static function start() {
  179. if (self::started()) {
  180. return true;
  181. }
  182. $id = self::id();
  183. session_write_close();
  184. self::_configureSession();
  185. self::_startSession();
  186. if (!$id && self::started()) {
  187. self::_checkValid();
  188. }
  189. self::$error = false;
  190. return self::started();
  191. }
  192. /**
  193. * Determine if Session has been started.
  194. *
  195. * @return boolean True if session has been started.
  196. */
  197. public static function started() {
  198. return isset($_SESSION) && session_id();
  199. }
  200. /**
  201. * Returns true if given variable is set in session.
  202. *
  203. * @param string $name Variable name to check for
  204. * @return boolean True if variable is there
  205. */
  206. public static function check($name = null) {
  207. if (empty($name)) {
  208. return false;
  209. }
  210. $result = Set::classicExtract($_SESSION, $name);
  211. return isset($result);
  212. }
  213. /**
  214. * Returns the Session id
  215. *
  216. * @param id $name string
  217. * @return string Session id
  218. */
  219. public static function id($id = null) {
  220. if ($id) {
  221. self::$id = $id;
  222. session_id(self::$id);
  223. }
  224. if (self::started()) {
  225. return session_id();
  226. }
  227. return self::$id;
  228. }
  229. /**
  230. * Removes a variable from session.
  231. *
  232. * @param string $name Session variable to remove
  233. * @return boolean Success
  234. */
  235. public static function delete($name) {
  236. if (self::check($name)) {
  237. if (in_array($name, self::$watchKeys)) {
  238. trigger_error(sprintf(__('Deleting session key {%s}'), $name), E_USER_NOTICE);
  239. }
  240. self::__overwrite($_SESSION, Set::remove($_SESSION, $name));
  241. return (self::check($name) == false);
  242. }
  243. self::__setError(2, sprintf(__("%s doesn't exist"), $name));
  244. return false;
  245. }
  246. /**
  247. * Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself
  248. *
  249. * @param array $old Set of old variables => values
  250. * @param array $new New set of variable => value
  251. * @access private
  252. */
  253. private static function __overwrite(&$old, $new) {
  254. if (!empty($old)) {
  255. foreach ($old as $key => $var) {
  256. if (!isset($new[$key])) {
  257. unset($old[$key]);
  258. }
  259. }
  260. }
  261. foreach ($new as $key => $var) {
  262. $old[$key] = $var;
  263. }
  264. }
  265. /**
  266. * Return error description for given error number.
  267. *
  268. * @param integer $errorNumber Error to set
  269. * @return string Error as string
  270. * @access private
  271. */
  272. private static function __error($errorNumber) {
  273. if (!is_array(self::$error) || !array_key_exists($errorNumber, self::$error)) {
  274. return false;
  275. } else {
  276. return self::$error[$errorNumber];
  277. }
  278. }
  279. /**
  280. * Returns last occurred error as a string, if any.
  281. *
  282. * @return mixed Error description as a string, or false.
  283. */
  284. public static function error() {
  285. if (self::$lastError) {
  286. return self::__error(self::$lastError);
  287. }
  288. return false;
  289. }
  290. /**
  291. * Returns true if session is valid.
  292. *
  293. * @return boolean Success
  294. */
  295. public static function valid() {
  296. if (self::read('Config')) {
  297. if (self::_validAgentAndTime() && self::$error === false) {
  298. self::$valid = true;
  299. } else {
  300. self::$valid = false;
  301. self::__setError(1, 'Session Highjacking Attempted !!!');
  302. }
  303. }
  304. return self::$valid;
  305. }
  306. /**
  307. * Tests that the user agent is valid and that the session hasn't 'timed out'.
  308. * Since timeouts are implemented in CakeSession it checks the current self::$time
  309. * against the time the session is set to expire. The User agent is only checked
  310. * if Session.checkAgent == true.
  311. *
  312. * @return boolean
  313. */
  314. protected static function _validAgentAndTime() {
  315. $validAgent = (
  316. Configure::read('Session.checkAgent') === false ||
  317. self::$_userAgent == self::read('Config.userAgent')
  318. );
  319. return ($validAgent && self::$time <= self::read('Config.time'));
  320. }
  321. /**
  322. * Get / Set the userAgent
  323. *
  324. * @param string $userAgent Set the userAgent
  325. * @return void
  326. */
  327. public static function userAgent($userAgent = null) {
  328. if ($userAgent) {
  329. self::$_userAgent = $userAgent;
  330. }
  331. return self::$_userAgent;
  332. }
  333. /**
  334. * Returns given session variable, or all of them, if no parameters given.
  335. *
  336. * @param mixed $name The name of the session variable (or a path as sent to Set.extract)
  337. * @return mixed The value of the session variable
  338. */
  339. public static function read($name = null) {
  340. if (is_null($name)) {
  341. return self::__returnSessionVars();
  342. }
  343. if (empty($name)) {
  344. return false;
  345. }
  346. $result = Set::classicExtract($_SESSION, $name);
  347. if (!is_null($result)) {
  348. return $result;
  349. }
  350. self::__setError(2, "$name doesn't exist");
  351. return null;
  352. }
  353. /**
  354. * Returns all session variables.
  355. *
  356. * @return mixed Full $_SESSION array, or false on error.
  357. * @access private
  358. */
  359. function __returnSessionVars() {
  360. if (!empty($_SESSION)) {
  361. return $_SESSION;
  362. }
  363. self::__setError(2, 'No Session vars set');
  364. return false;
  365. }
  366. /**
  367. * Tells Session to write a notification when a certain session path or subpath is written to
  368. *
  369. * @param mixed $var The variable path to watch
  370. * @return void
  371. */
  372. public static function watch($var) {
  373. if (empty($var)) {
  374. return false;
  375. }
  376. if (!in_array($var, self::$watchKeys, true)) {
  377. self::$watchKeys[] = $var;
  378. }
  379. }
  380. /**
  381. * Tells Session to stop watching a given key path
  382. *
  383. * @param mixed $var The variable path to watch
  384. * @return void
  385. */
  386. public static function ignore($var) {
  387. if (!in_array($var, self::$watchKeys)) {
  388. debug("NOT");
  389. return;
  390. }
  391. foreach (self::$watchKeys as $i => $key) {
  392. if ($key == $var) {
  393. unset(self::$watchKeys[$i]);
  394. self::$watchKeys = array_values(self::$watchKeys);
  395. return;
  396. }
  397. }
  398. }
  399. /**
  400. * Writes value to given session variable name.
  401. *
  402. * @param mixed $name Name of variable
  403. * @param string $value Value to write
  404. * @return boolean True if the write was successful, false if the write failed
  405. */
  406. public static function write($name, $value = null) {
  407. if (empty($name)) {
  408. return false;
  409. }
  410. $write = $name;
  411. if (!is_array($name)) {
  412. $write = array($name => $value);
  413. }
  414. foreach ($write as $key => $val) {
  415. if (in_array($key, self::$watchKeys)) {
  416. trigger_error(sprintf(__('Writing session key {%s}: %s'), $key, Debugger::exportVar($val)), E_USER_NOTICE);
  417. }
  418. self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
  419. if (Set::classicExtract($_SESSION, $key) !== $val) {
  420. return false;
  421. }
  422. }
  423. return true;
  424. }
  425. /**
  426. * Helper method to destroy invalid sessions.
  427. *
  428. * @return void
  429. */
  430. public static function destroy() {
  431. if (self::started()) {
  432. session_destroy();
  433. }
  434. self::clear();
  435. }
  436. /**
  437. * Clears the session, the session id, and renew's the session.
  438. *
  439. * @return void
  440. */
  441. public static function clear() {
  442. $_SESSION = null;
  443. self::$id = null;
  444. self::start();
  445. self::renew();
  446. }
  447. /**
  448. * Helper method to initialize a session, based on Cake core settings.
  449. *
  450. * Sessions can be configured with a few shortcut names as well as have any number of ini settings declared.
  451. *
  452. * @return void
  453. * @throws Exception Throws exceptions when ini_set() fails.
  454. */
  455. protected static function _configureSession() {
  456. $sessionConfig = Configure::read('Session');
  457. $iniSet = function_exists('ini_set');
  458. if (isset($sessionConfig['defaults'])) {
  459. $defaults = self::_defaultConfig($sessionConfig['defaults']);
  460. if ($defaults) {
  461. $sessionConfig = Set::merge($defaults, $sessionConfig);
  462. }
  463. }
  464. if (!isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS')) {
  465. $sessionConfig['ini']['session.cookie_secure'] = 1;
  466. }
  467. if (isset($sessionConfig['timeout']) && !isset($sessionConfig['cookieTimeout'])) {
  468. $sessionConfig['cookieTimeout'] = $sessionConfig['timeout'];
  469. }
  470. if (!isset($sessionConfig['ini']['session.cookie_lifetime'])) {
  471. $sessionConfig['ini']['session.cookie_lifetime'] = $sessionConfig['cookieTimeout'] * 60;
  472. }
  473. if (!isset($sessionConfig['ini']['session.name'])) {
  474. $sessionConfig['ini']['session.name'] = $sessionConfig['cookie'];
  475. }
  476. if (!empty($sessionConfig['handler'])) {
  477. $sessionConfig['ini']['session.save_handler'] = 'user';
  478. }
  479. if (empty($_SESSION)) {
  480. if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) {
  481. foreach ($sessionConfig['ini'] as $setting => $value) {
  482. if (ini_set($setting, $value) === false) {
  483. throw new Exception(sprintf(
  484. __('Unable to configure the session, setting %s failed.'),
  485. $setting
  486. ));
  487. }
  488. }
  489. }
  490. }
  491. if (!empty($sessionConfig['handler']) && !isset($sessionConfig['handler']['engine'])) {
  492. call_user_func_array('session_set_save_handler', $sessionConfig['handler']);
  493. }
  494. if (!empty($sessionConfig['handler']['engine'])) {
  495. $handler = self::_getHandler($sessionConfig['handler']['engine']);
  496. session_set_save_handler(
  497. array($handler, 'open'),
  498. array($handler, 'close'),
  499. array($handler, 'read'),
  500. array($handler, 'write'),
  501. array($handler, 'destroy'),
  502. array($handler, 'gc')
  503. );
  504. }
  505. Configure::write('Session', $sessionConfig);
  506. self::$sessionTime = self::$time + ($sessionConfig['timeout'] * 60);
  507. }
  508. /**
  509. * Find the handler class and make sure it implements the correct interface.
  510. *
  511. * @return void
  512. */
  513. protected static function _getHandler($handler) {
  514. list($plugin, $class) = pluginSplit($handler, true);
  515. $found = App::import('Lib', $plugin . 'session/' . $class);
  516. if (!$found) {
  517. App::import('Core', 'session/' . $class);
  518. }
  519. if (!class_exists($class)) {
  520. throw new Exception(sprintf(__('Could not load %s to handle the session.'), $class));
  521. }
  522. $handler = new $class();
  523. if ($handler instanceof CakeSessionHandlerInterface) {
  524. return $handler;
  525. }
  526. throw new Exception(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.'));
  527. }
  528. /**
  529. * Get one of the prebaked default session configurations.
  530. *
  531. * @return void
  532. */
  533. protected static function _defaultConfig($name) {
  534. $defaults = array(
  535. 'php' => array(
  536. 'cookie' => 'CAKEPHP',
  537. 'timeout' => 240,
  538. 'cookieTimeout' => 240,
  539. 'ini' => array(
  540. 'session.use_trans_sid' => 0,
  541. 'session.cookie_path' => self::$path,
  542. 'session.save_handler' => 'files'
  543. )
  544. ),
  545. 'cake' => array(
  546. 'cookie' => 'CAKEPHP',
  547. 'timeout' => 240,
  548. 'cookieTimeout' => 240,
  549. 'ini' => array(
  550. 'session.use_trans_sid' => 0,
  551. 'url_rewriter.tags' => '',
  552. 'session.serialize_handler' => 'php',
  553. 'session.use_cookies' => 1,
  554. 'session.cookie_path' => self::$path,
  555. 'session.auto_start' => 0,
  556. 'session.save_path' => TMP . 'sessions',
  557. 'session.save_handler' => 'files'
  558. )
  559. ),
  560. 'cache' => array(
  561. 'cookie' => 'CAKEPHP',
  562. 'timeout' => 240,
  563. 'cookieTimeout' => 240,
  564. 'ini' => array(
  565. 'session.use_trans_sid' => 0,
  566. 'url_rewriter.tags' => '',
  567. 'session.auto_start' => 0,
  568. 'session.use_cookies' => 1,
  569. 'session.cookie_path' => self::$path,
  570. 'session.save_handler' => 'user',
  571. ),
  572. 'handler' => array(
  573. 'engine' => 'CacheSession',
  574. 'config' => 'default'
  575. )
  576. ),
  577. 'database' => array(
  578. 'cookie' => 'CAKEPHP',
  579. 'timeout' => 240,
  580. 'cookieTimeout' => 240,
  581. 'ini' => array(
  582. 'session.use_trans_sid' => 0,
  583. 'url_rewriter.tags' => '',
  584. 'session.auto_start' => 0,
  585. 'session.use_cookies' => 1,
  586. 'session.cookie_path' => self::$path,
  587. 'session.save_handler' => 'user',
  588. 'session.serialize_handler' => 'php',
  589. ),
  590. 'handler' => array(
  591. 'engine' => 'DatabaseSession',
  592. 'model' => 'Session'
  593. )
  594. )
  595. );
  596. if (isset($defaults[$name])) {
  597. return $defaults[$name];
  598. }
  599. return false;
  600. }
  601. /**
  602. * Helper method to start a session
  603. *
  604. * @return boolean Success
  605. */
  606. protected static function _startSession() {
  607. if (headers_sent()) {
  608. if (empty($_SESSION)) {
  609. $_SESSION = array();
  610. }
  611. } elseif (!isset($_SESSION)) {
  612. session_cache_limiter ("must-revalidate");
  613. session_start();
  614. header ('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
  615. } else {
  616. session_start();
  617. }
  618. return true;
  619. }
  620. /**
  621. * Helper method to create a new session.
  622. *
  623. * @return void
  624. */
  625. protected static function _checkValid() {
  626. if (self::read('Config')) {
  627. $sessionConfig = Configure::read('Session');
  628. if (self::_validAgentAndTime()) {
  629. $time = self::read('Config.time');
  630. self::write('Config.time', self::$sessionTime);
  631. if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) {
  632. $check = self::read('Config.countdown');
  633. $check -= 1;
  634. self::write('Config.countdown', $check);
  635. if (time() > ($time - ($sessionConfig['timeout'] * 60) + 2) || $check < 1) {
  636. self::renew();
  637. self::write('Config.countdown', self::$requestCountdown);
  638. }
  639. }
  640. self::$valid = true;
  641. } else {
  642. self::destroy();
  643. self::$valid = false;
  644. self::__setError(1, 'Session Highjacking Attempted !!!');
  645. }
  646. } else {
  647. self::write('Config.userAgent', self::$_userAgent);
  648. self::write('Config.time', self::$sessionTime);
  649. self::write('Config.countdown', self::$requestCountdown);
  650. self::$valid = true;
  651. }
  652. }
  653. /**
  654. * Restarts this session.
  655. *
  656. * @return void
  657. */
  658. public static function renew() {
  659. if (session_id()) {
  660. if (session_id() != '' || isset($_COOKIE[session_name()])) {
  661. setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path);
  662. }
  663. session_regenerate_id(true);
  664. }
  665. }
  666. /**
  667. * Helper method to set an internal error message.
  668. *
  669. * @param integer $errorNumber Number of the error
  670. * @param string $errorMessage Description of the error
  671. * @return void
  672. * @access private
  673. */
  674. private static function __setError($errorNumber, $errorMessage) {
  675. if (self::$error === false) {
  676. self::$error = array();
  677. }
  678. self::$error[$errorNumber] = $errorMessage;
  679. self::$lastError = $errorNumber;
  680. }
  681. }
  682. /**
  683. * Interface for Session handlers. Custom session handler classes should implement
  684. * this interface as it allows CakeSession know how to map methods to session_set_save_handler()
  685. *
  686. * @package cake.libs
  687. */
  688. interface CakeSessionHandlerInterface {
  689. /**
  690. * Method called on open of a session.
  691. *
  692. * @return boolean Success
  693. */
  694. public function open();
  695. /**
  696. * Method called on close of a session.
  697. *
  698. * @return boolean Success
  699. */
  700. public function close();
  701. /**
  702. * Method used to read from a session.
  703. *
  704. * @param mixed $id The key of the value to read
  705. * @return mixed The value of the key or false if it does not exist
  706. */
  707. public function read($id);
  708. /**
  709. * Helper function called on write for sessions.
  710. *
  711. * @param integer $id ID that uniquely identifies session in database
  712. * @param mixed $data The value of the data to be saved.
  713. * @return boolean True for successful write, false otherwise.
  714. */
  715. public function write($id, $data);
  716. /**
  717. * Method called on the destruction of a session.
  718. *
  719. * @param integer $id ID that uniquely identifies session in database
  720. * @return boolean True for successful delete, false otherwise.
  721. */
  722. public function destroy($id);
  723. /**
  724. * Run the Garbage collection on the session storage. This method should vacuum all
  725. * expired or dead sessions.
  726. *
  727. * @param integer $expires Timestamp (defaults to current time)
  728. * @return boolean Success
  729. */
  730. public function gc($expires = null);
  731. }
  732. // Initialize the session
  733. CakeSession::init();