* @package taoLti */ class CookieUtils extends tao_actions_CommonModule { /** * Verifies whenever or not the cookie was set correctly * Redirects the user to his destination if it was * or prompts the user to restore the session if it wasn't */ public function verifyCookie() { $url = $this->getRequestParameter('redirect'); $url = rawurldecode($url); $session = $this->getRequestParameter('session'); if (session_id() == $session) { $this->forwardUrl($url); } else { $this->setData('session', $session); $this->setData('redirect', $url); $this->setView('cookieError.tpl'); } } /** * Closses the current session, restores the session provided * in the parameter session, regenerates a new sessionid and * redirects the user to the original address * @throws \common_Exception */ public function restoreSession() { $sessId = $this->getRequestParameter('session'); $url = $this->getRequestParameter('redirect'); if (session_id() != $sessId) { common_Logger::i('Changing session to ' . $sessId); session_unset(); session_destroy(); session_id($sessId); session_start(); if (session_id() != $sessId) { $this->returnError(__('Unable to restore Session')); } session_regenerate_id(true); common_Logger::d('regenerated session to id \'' . session_id() . '\''); } else { common_Logger::w('Restore session called with correct session id \'' . session_id() . '\''); } $this->forwardUrl($url); } }