Mage_Core_Model_Session_Abstract Class Reference

Inheritance diagram for Mage_Core_Model_Session_Abstract:

Mage_Core_Model_Session_Abstract_Varien Varien_Object Mage_Admin_Model_Session Mage_Adminhtml_Model_Session Mage_Adminhtml_Model_Session_Quote Mage_AmazonPayments_Model_Session Mage_Api_Model_Session Mage_Catalog_Model_Session Mage_CatalogSearch_Model_Session Mage_Checkout_Model_Session Mage_Core_Model_Session Mage_Customer_Model_Session Mage_Install_Model_Session Mage_Newsletter_Model_Session Mage_Paypal_Model_Session Mage_PaypalUk_Model_Session Mage_Reports_Model_Session Mage_Review_Model_Session Mage_Rss_Model_Session Mage_Tag_Model_Session Mage_Wishlist_Model_Session

List of all members.

Public Member Functions

 init ($namespace, $sessionName=null)
 getCookieDomain ()
 getCookiePath ()
 getCookieLifetime ()
 useValidateRemoteAddr ()
 useValidateHttpVia ()
 useValidateHttpXForwardedFor ()
 useValidateHttpUserAgent ()
 getValidateHttpUserAgentSkip ()
 getMessages ($clear=false)
 addException (Exception $exception, $alternativeText)
 addMessage (Mage_Core_Model_Message_Abstract $message)
 addError ($message)
 addWarning ($message)
 addNotice ($message)
 addSuccess ($message)
 addMessages ($messages)
 setSessionId ($id=null)
 getEncryptedSessionId ()
 getSessionIdQueryParam ()
 setSkipSessionIdFlag ($flag)
 getSkipSessionIdFlag ()
 getSessionIdForHost ($urlHost)
 isValidForHost ($host)
 addHost ($host)
 getSessionHosts ()
 getSessionSaveMethod ()
 getSessionSavePath ()

Public Attributes

const XML_PATH_COOKIE_DOMAIN = 'web/cookie/cookie_domain'
const XML_PATH_COOKIE_PATH = 'web/cookie/cookie_path'
const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime'
const XML_NODE_SESSION_SAVE = 'global/session_save'
const XML_NODE_SESSION_SAVE_PATH = 'global/session_save_path'
const XML_PATH_USE_REMOTE_ADDR = 'web/session/use_remote_addr'
const XML_PATH_USE_HTTP_VIA = 'web/session/use_http_via'
const XML_PATH_USE_X_FORWARDED = 'web/session/use_http_x_forwarded_for'
const XML_PATH_USE_USER_AGENT = 'web/session/use_http_user_agent'
const XML_NODE_USET_AGENT_SKIP = 'global/session/validation/http_user_agent_skip'
const XML_PATH_LOG_EXCEPTION_FILE = 'dev/log/exception_file'
const SESSION_ID_QUERY_PARAM = 'SID'

Protected Attributes

 $_skipSessionIdFlag = false

Static Protected Attributes

static $_urlHostCache = array()
static $_encryptedSessionId


Detailed Description

Definition at line 35 of file Abstract.php.


Member Function Documentation

addError ( message  ) 

Adding new error message

Parameters:
string $message
Returns:
Mage_Core_Model_Session_Abstract

Reimplemented in Mage_Newsletter_Model_Session.

Definition at line 248 of file Abstract.php.

00249     {
00250         $this->addMessage(Mage::getSingleton('core/message')->error($message));
00251         return $this;
00252     }

addException ( Exception $  exception,
alternativeText 
)

Not Mage exeption handling

Parameters:
Exception $exception
string $alternativeText
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 216 of file Abstract.php.

00217     {
00218         // log exception to exceptions log
00219         $message = sprintf('Exception message: %s%sTrace: %s',
00220             $exception->getMessage(),
00221             "\n",
00222             $exception->getTraceAsString());
00223         $file    = Mage::getStoreConfig(self::XML_PATH_LOG_EXCEPTION_FILE);
00224         Mage::log($message, Zend_Log::DEBUG, $file);
00225 
00226         $this->addMessage(Mage::getSingleton('core/message')->error($alternativeText));
00227         return $this;
00228     }

addHost ( host  ) 

Add hostname to session

Parameters:
string $host
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 436 of file Abstract.php.

00437     {
00438         if ($host === true) {
00439             if (!$host = Mage::app()->getFrontController()->getRequest()->getHttpHost()) {
00440                 return $this;
00441             }
00442         }
00443 
00444         if (!$host) {
00445             return $this;
00446         }
00447 
00448         $hosts = $this->getSessionHosts();
00449         $hosts[$host] = true;
00450         $this->setSessionHosts($hosts);
00451         return $this;
00452     }

addMessage ( Mage_Core_Model_Message_Abstract message  ) 

Adding new message to message collection

Parameters:
Mage_Core_Model_Message_Abstract $message
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 236 of file Abstract.php.

00237     {
00238         $this->getMessages()->add($message);
00239         return $this;
00240     }

addMessages ( messages  ) 

Adding messages array to message collection

Parameters:
array $messages
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 296 of file Abstract.php.

00297     {
00298         if (is_array($messages)) {
00299             foreach ($messages as $message) {
00300                 $this->addMessage($message);
00301             }
00302         }
00303         return $this;
00304     }

addNotice ( message  ) 

Adding new nitice message

Parameters:
string $message
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 272 of file Abstract.php.

00273     {
00274         $this->addMessage(Mage::getSingleton('core/message')->notice($message));
00275         return $this;
00276     }

addSuccess ( message  ) 

Adding new success message

Parameters:
string $message
Returns:
Mage_Core_Model_Session_Abstract

Reimplemented in Mage_Newsletter_Model_Session.

Definition at line 284 of file Abstract.php.

00285     {
00286         $this->addMessage(Mage::getSingleton('core/message')->success($message));
00287         return $this;
00288     }

addWarning ( message  ) 

Adding new warning message

Parameters:
string $message
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 260 of file Abstract.php.

00261     {
00262         $this->addMessage(Mage::getSingleton('core/message')->warning($message));
00263         return $this;
00264     }

getCookieDomain (  ) 

Retrieve Cookie domain

Returns:
string

Definition at line 93 of file Abstract.php.

00094     {
00095         return $this->getCookie()->getDomain();
00096     }

getCookieLifetime (  ) 

Retrieve cookie lifetime

Returns:
int

Definition at line 113 of file Abstract.php.

00114     {
00115         return $this->getCookie()->getLifetime();
00116     }

getCookiePath (  ) 

Retrieve cookie path

Returns:
string

Definition at line 103 of file Abstract.php.

00104     {
00105         return $this->getCookie()->getPath();
00106     }

getEncryptedSessionId (  ) 

Get ecrypted session identifuer No reason use crypt key for session id encryption we can use session identifier as is

Returns:
string

Definition at line 338 of file Abstract.php.

00339     {
00340         if (!self::$_encryptedSessionId) {
00341 //            $helper = Mage::helper('core');
00342 //            if (!$helper) {
00343 //                return $this;
00344 //            }
00345 //            self::$_encryptedSessionId = $helper->encrypt($this->getSessionId());
00346             self::$_encryptedSessionId = $this->getSessionId();
00347         }
00348         return self::$_encryptedSessionId;
00349     }

getMessages ( clear = false  ) 

Retrieve messages from session

Parameters:
bool $clear
Returns:
Mage_Core_Model_Message_Collection

Definition at line 195 of file Abstract.php.

00196     {
00197         if (!$this->getData('messages')) {
00198             $this->setMessages(Mage::getModel('core/message_collection'));
00199         }
00200 
00201         if ($clear) {
00202             $messages = clone $this->getData('messages');
00203             $this->getData('messages')->clear();
00204             return $messages;
00205         }
00206         return $this->getData('messages');
00207     }

getSessionHosts (  ) 

Retrieve session hostnames

Returns:
array

Definition at line 459 of file Abstract.php.

00460     {
00461         return $this->getData('session_hosts');
00462     }

getSessionIdForHost ( urlHost  ) 

If the host was switched but session cookie won't recognize it - add session id to query

Parameters:
string $urlHost can be host or url
Returns:
string {session_id_key}={session_id_encrypted}

Definition at line 388 of file Abstract.php.

00389     {
00390         if ($this->getSkipSessionIdFlag() === true) {
00391             return '';
00392         }
00393 
00394         if (!$httpHost = Mage::app()->getFrontController()->getRequest()->getHttpHost()) {
00395             return '';
00396         }
00397 
00398         $urlHostArr = explode('/', $urlHost, 4);
00399         if (!empty($urlHostArr[2])) {
00400             $urlHost = $urlHostArr[2];
00401         }
00402 
00403         if (!isset(self::$_urlHostCache[$urlHost])) {
00404             $urlHostArr = explode(':', $urlHost);
00405             $urlHost = $urlHostArr[0];
00406 
00407             if ($httpHost !== $urlHost && !$this->isValidForHost($urlHost)) {
00408                 $sessionId = $this->getEncryptedSessionId();
00409             } else {
00410                 $sessionId = '';
00411             }
00412             self::$_urlHostCache[$urlHost] = $sessionId;
00413         }
00414         return self::$_urlHostCache[$urlHost];
00415     }

getSessionIdQueryParam (  ) 

Definition at line 351 of file Abstract.php.

00352     {
00353         $_sessionName = $this->getSessionName();
00354         if ($_sessionName && $queryParam = (string)Mage::getConfig()->getNode($_sessionName . '/session/query_param')) {
00355             return $queryParam;
00356         }
00357         return self::SESSION_ID_QUERY_PARAM;
00358     }

getSessionSaveMethod (  ) 

Retrieve session save method

Returns:
string

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 469 of file Abstract.php.

00470     {
00471         if (Mage::isInstalled() && $sessionSave = Mage::getConfig()->getNode(self::XML_NODE_SESSION_SAVE)) {
00472             return $sessionSave;
00473         }
00474         return parent::getSessionSaveMethod();
00475     }

getSessionSavePath (  ) 

Get sesssion save path

Returns:
string

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 482 of file Abstract.php.

00483     {
00484         if (Mage::isInstalled() && $sessionSavePath = Mage::getConfig()->getNode(self::XML_NODE_SESSION_SAVE_PATH)) {
00485             return $sessionSavePath;
00486         }
00487         return parent::getSessionSavePath();
00488     }

getSkipSessionIdFlag (  ) 

Retrieve session id skip flag

Returns:
bool

Definition at line 377 of file Abstract.php.

00378     {
00379         return $this->_skipSessionIdFlag;
00380     }

getValidateHttpUserAgentSkip (  ) 

Retrieve skip User Agent validation strings (Flash etc)

Returns:
array

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 179 of file Abstract.php.

00180     {
00181         $userAgents = array();
00182         $skip = Mage::getConfig()->getNode(self::XML_NODE_USET_AGENT_SKIP);
00183         foreach ($skip->children() as $userAgent) {
00184             $userAgents[] = (string)$userAgent;
00185         }
00186         return $userAgents;
00187     }

init ( namespace,
sessionName = null 
)

Init session

Parameters:
string $namespace
string $sessionName
Returns:
Mage_Core_Model_Session_Abstract

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Reimplemented in Mage_Api_Model_Session.

Definition at line 81 of file Abstract.php.

00082     {
00083         parent::init($namespace, $sessionName);
00084         $this->addHost(true);
00085         return $this;
00086     }

isValidForHost ( host  ) 

Check is valid session for hostname

Parameters:
string $host
Returns:
bool

Definition at line 423 of file Abstract.php.

00424     {
00425         $hostArr = explode(':', $host);
00426         $hosts = $this->getSessionHosts();
00427         return (!empty($hosts[$hostArr[0]]));
00428     }

setSessionId ( id = null  ) 

Specify session identifier

Parameters:
string|null $id
Returns:
Mage_Core_Model_Session_Abstract

No reason use crypt key for session

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Reimplemented in Mage_Api_Model_Session.

Definition at line 312 of file Abstract.php.

00313     {
00314         if (is_null($id)) {
00315             $_queryParam = $this->getSessionIdQueryParam();
00316             if (isset($_GET[$_queryParam])) {
00317                 $id = $_GET[$_queryParam];
00318                 /**
00319                  * No reason use crypt key for session
00320                  */
00321 //                if ($tryId = Mage::helper('core')->decrypt($_GET[self::SESSION_ID_QUERY_PARAM])) {
00322 //                    $id = $tryId;
00323 //                }
00324             }
00325         }
00326 
00327         $this->addHost(true);
00328         return parent::setSessionId($id);
00329     }

setSkipSessionIdFlag ( flag  ) 

Set skip flag if need skip generating of _GET session_id_key param

Parameters:
bool $flag
Returns:
Mage_Core_Model_Session_Abstract

Definition at line 366 of file Abstract.php.

00367     {
00368         $this->_skipSessionIdFlag = $flag;
00369         return $this;
00370     }

useValidateHttpUserAgent (  ) 

Use HTTP_USER_AGENT in validator key

Returns:
bool

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 165 of file Abstract.php.

00166     {
00167         $use = Mage::getStoreConfig(self::XML_PATH_USE_USER_AGENT);
00168         if (is_null($use)) {
00169             return parent::useValidateHttpUserAgent();
00170         }
00171         return (bool)$use;
00172     }

useValidateHttpVia (  ) 

Use HTTP_VIA in validator key

Returns:
bool

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 137 of file Abstract.php.

00138     {
00139         $use = Mage::getStoreConfig(self::XML_PATH_USE_HTTP_VIA);
00140         if (is_null($use)) {
00141             return parent::useValidateHttpVia();
00142         }
00143         return (bool)$use;
00144     }

useValidateHttpXForwardedFor (  ) 

Use HTTP_X_FORWARDED_FOR in validator key

Returns:
bool

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 151 of file Abstract.php.

00152     {
00153         $use = Mage::getStoreConfig(self::XML_PATH_USE_X_FORWARDED);
00154         if (is_null($use)) {
00155             return parent::useValidateHttpXForwardedFor();
00156         }
00157         return (bool)$use;
00158     }

useValidateRemoteAddr (  ) 

Use REMOTE_ADDR in validator key

Returns:
bool

Reimplemented from Mage_Core_Model_Session_Abstract_Varien.

Definition at line 123 of file Abstract.php.

00124     {
00125         $use = Mage::getStoreConfig(self::XML_PATH_USE_REMOTE_ADDR);
00126         if (is_null($use)) {
00127             return parent::useValidateRemoteAddr();
00128         }
00129         return (bool)$use;
00130     }


Member Data Documentation

$_encryptedSessionId [static, protected]

Definition at line 65 of file Abstract.php.

$_skipSessionIdFlag = false [protected]

Definition at line 72 of file Abstract.php.

$_urlHostCache = array() [static, protected]

Definition at line 58 of file Abstract.php.

const SESSION_ID_QUERY_PARAM = 'SID'

Definition at line 51 of file Abstract.php.

const XML_NODE_SESSION_SAVE = 'global/session_save'

Definition at line 40 of file Abstract.php.

const XML_NODE_SESSION_SAVE_PATH = 'global/session_save_path'

Definition at line 41 of file Abstract.php.

const XML_NODE_USET_AGENT_SKIP = 'global/session/validation/http_user_agent_skip'

Definition at line 48 of file Abstract.php.

const XML_PATH_COOKIE_DOMAIN = 'web/cookie/cookie_domain'

Definition at line 37 of file Abstract.php.

const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime'

Definition at line 39 of file Abstract.php.

const XML_PATH_COOKIE_PATH = 'web/cookie/cookie_path'

Definition at line 38 of file Abstract.php.

const XML_PATH_LOG_EXCEPTION_FILE = 'dev/log/exception_file'

Definition at line 49 of file Abstract.php.

const XML_PATH_USE_HTTP_VIA = 'web/session/use_http_via'

Definition at line 44 of file Abstract.php.

const XML_PATH_USE_REMOTE_ADDR = 'web/session/use_remote_addr'

Definition at line 43 of file Abstract.php.

const XML_PATH_USE_USER_AGENT = 'web/session/use_http_user_agent'

Definition at line 46 of file Abstract.php.

const XML_PATH_USE_X_FORWARDED = 'web/session/use_http_x_forwarded_for'

Definition at line 45 of file Abstract.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:00 2009 for Magento by  doxygen 1.5.8