Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage
  • Mage_Adminhtml_Block_Html_Date
  • Mage_Adminhtml_Block_Html_Select
  • Mage_Api_Model_Wsdl_Config_Element
  • Mage_Captcha_Adminhtml_RefreshController
  • Mage_Captcha_RefreshController
  • Mage_Core_AjaxController
  • Mage_Core_Block_Abstract
  • Mage_Core_Block_Flush
  • Mage_Core_Block_Html_Calendar
  • Mage_Core_Block_Html_Date
  • Mage_Core_Block_Html_Link
  • Mage_Core_Block_Html_Select
  • Mage_Core_Block_Messages
  • Mage_Core_Block_Profiler
  • Mage_Core_Block_Store_Switcher
  • Mage_Core_Block_Template
  • Mage_Core_Block_Template_Facade
  • Mage_Core_Block_Template_Smarty
  • Mage_Core_Block_Template_Zend
  • Mage_Core_Block_Text
  • Mage_Core_Block_Text_List
  • Mage_Core_Block_Text_List_Item
  • Mage_Core_Block_Text_List_Link
  • Mage_Core_Block_Text_Tag
  • Mage_Core_Block_Text_Tag_Css
  • Mage_Core_Block_Text_Tag_Css_Admin
  • Mage_Core_Block_Text_Tag_Debug
  • Mage_Core_Block_Text_Tag_Js
  • Mage_Core_Block_Text_Tag_Meta
  • Mage_Core_Controller_Front_Action
  • Mage_Core_Controller_Front_Router
  • Mage_Core_Controller_Request_Http
  • Mage_Core_Controller_Response_Http
  • Mage_Core_Controller_Varien_Action
  • Mage_Core_Controller_Varien_Front
  • Mage_Core_Controller_Varien_Router_Abstract
  • Mage_Core_Controller_Varien_Router_Admin
  • Mage_Core_Controller_Varien_Router_Default
  • Mage_Core_Controller_Varien_Router_Standard
  • Mage_Core_Helper_Abstract
  • Mage_Core_Helper_Cookie
  • Mage_Core_Helper_Data
  • Mage_Core_Helper_File_Storage
  • Mage_Core_Helper_File_Storage_Database
  • Mage_Core_Helper_Hint
  • Mage_Core_Helper_Http
  • Mage_Core_Helper_Js
  • Mage_Core_Helper_String
  • Mage_Core_Helper_Translate
  • Mage_Core_Helper_Url
  • Mage_Core_Helper_Url_Rewrite
  • Mage_Core_IndexController
  • Mage_Core_Model_Abstract
  • Mage_Core_Model_App
  • Mage_Core_Model_App_Area
  • Mage_Core_Model_App_Emulation
  • Mage_Core_Model_Cache
  • Mage_Core_Model_Calculator
  • Mage_Core_Model_Config
  • Mage_Core_Model_Config_Base
  • Mage_Core_Model_Config_Data
  • Mage_Core_Model_Config_Element
  • Mage_Core_Model_Config_Options
  • Mage_Core_Model_Config_System
  • Mage_Core_Model_Cookie
  • Mage_Core_Model_Date
  • Mage_Core_Model_Design
  • Mage_Core_Model_Design_Package
  • Mage_Core_Model_Design_Source_Design
  • Mage_Core_Model_Email
  • Mage_Core_Model_Email_Info
  • Mage_Core_Model_Email_Template
  • Mage_Core_Model_Email_Template_Filter
  • Mage_Core_Model_Email_Template_Mailer
  • Mage_Core_Model_Email_Transport
  • Mage_Core_Model_Encryption
  • Mage_Core_Model_File_Storage
  • Mage_Core_Model_File_Storage_Abstract
  • Mage_Core_Model_File_Storage_Database
  • Mage_Core_Model_File_Storage_Database_Abstract
  • Mage_Core_Model_File_Storage_Directory_Database
  • Mage_Core_Model_File_Storage_File
  • Mage_Core_Model_File_Storage_Flag
  • Mage_Core_Model_File_Uploader
  • Mage_Core_Model_File_Validator_AvailablePath
  • Mage_Core_Model_File_Validator_NotProtectedExtension
  • Mage_Core_Model_Flag
  • Mage_Core_Model_Input_Filter
  • Mage_Core_Model_Input_Filter_MaliciousCode
  • Mage_Core_Model_Language
  • Mage_Core_Model_Layout
  • Mage_Core_Model_Layout_Data
  • Mage_Core_Model_Layout_Element
  • Mage_Core_Model_Layout_Update
  • Mage_Core_Model_Locale
  • Mage_Core_Model_Locale_Config
  • Mage_Core_Model_Log_Adapter
  • Mage_Core_Model_Magento_Api
  • Mage_Core_Model_Magento_Api_V2
  • Mage_Core_Model_Message
  • Mage_Core_Model_Message_Abstract
  • Mage_Core_Model_Message_Collection
  • Mage_Core_Model_Message_Error
  • Mage_Core_Model_Message_Notice
  • Mage_Core_Model_Message_Success
  • Mage_Core_Model_Message_Warning
  • Mage_Core_Model_Mysql4_Abstract
  • Mage_Core_Model_Mysql4_Cache
  • Mage_Core_Model_Mysql4_Collection_Abstract
  • Mage_Core_Model_Mysql4_Config
  • Mage_Core_Model_Mysql4_Config_Data
  • Mage_Core_Model_Mysql4_Config_Data_Collection
  • Mage_Core_Model_Mysql4_Design
  • Mage_Core_Model_Mysql4_Design_Collection
  • Mage_Core_Model_Mysql4_Design_Package_Collection
  • Mage_Core_Model_Mysql4_Design_Theme
  • Mage_Core_Model_Mysql4_Email_Template
  • Mage_Core_Model_Mysql4_Email_Template_Collection
  • Mage_Core_Model_Mysql4_File_Storage_Abstract
  • Mage_Core_Model_Mysql4_File_Storage_Database
  • Mage_Core_Model_Mysql4_File_Storage_Directory_Database
  • Mage_Core_Model_Mysql4_File_Storage_File
  • Mage_Core_Model_Mysql4_Flag
  • Mage_Core_Model_Mysql4_Language
  • Mage_Core_Model_Mysql4_Language_Collection
  • Mage_Core_Model_Mysql4_Layout
  • Mage_Core_Model_Mysql4_Resource
  • Mage_Core_Model_Mysql4_Session
  • Mage_Core_Model_Mysql4_Store
  • Mage_Core_Model_Mysql4_Store_Collection
  • Mage_Core_Model_Mysql4_Store_Group
  • Mage_Core_Model_Mysql4_Store_Group_Collection
  • Mage_Core_Model_Mysql4_Translate
  • Mage_Core_Model_Mysql4_Translate_String
  • Mage_Core_Model_Mysql4_Url_Rewrite
  • Mage_Core_Model_Mysql4_Url_Rewrite_Collection
  • Mage_Core_Model_Mysql4_Variable
  • Mage_Core_Model_Mysql4_Variable_Collection
  • Mage_Core_Model_Mysql4_Website
  • Mage_Core_Model_Mysql4_Website_Collection
  • Mage_Core_Model_Observer
  • Mage_Core_Model_Resource
  • Mage_Core_Model_Resource_Abstract
  • Mage_Core_Model_Resource_Cache
  • Mage_Core_Model_Resource_Config
  • Mage_Core_Model_Resource_Config_Data
  • Mage_Core_Model_Resource_Config_Data_Collection
  • Mage_Core_Model_Resource_Db_Abstract
  • Mage_Core_Model_Resource_Db_Collection_Abstract
  • Mage_Core_Model_Resource_Design
  • Mage_Core_Model_Resource_Design_Collection
  • Mage_Core_Model_Resource_Design_Package_Collection
  • Mage_Core_Model_Resource_Email_Template
  • Mage_Core_Model_Resource_Email_Template_Collection
  • Mage_Core_Model_Resource_Entity_Abstract
  • Mage_Core_Model_Resource_Entity_Table
  • Mage_Core_Model_Resource_File_Storage_Abstract
  • Mage_Core_Model_Resource_File_Storage_Database
  • Mage_Core_Model_Resource_File_Storage_Directory_Database
  • Mage_Core_Model_Resource_File_Storage_File
  • Mage_Core_Model_Resource_Flag
  • Mage_Core_Model_Resource_Helper_Abstract
  • Mage_Core_Model_Resource_Helper_Mysql4
  • Mage_Core_Model_Resource_Iterator
  • Mage_Core_Model_Resource_Language
  • Mage_Core_Model_Resource_Language_Collection
  • Mage_Core_Model_Resource_Layout
  • Mage_Core_Model_Resource_Resource
  • Mage_Core_Model_Resource_Session
  • Mage_Core_Model_Resource_Setup
  • Mage_Core_Model_Resource_Setup_Query_Modifier
  • Mage_Core_Model_Resource_Store
  • Mage_Core_Model_Resource_Store_Collection
  • Mage_Core_Model_Resource_Store_Group
  • Mage_Core_Model_Resource_Store_Group_Collection
  • Mage_Core_Model_Resource_Transaction
  • Mage_Core_Model_Resource_Translate
  • Mage_Core_Model_Resource_Translate_String
  • Mage_Core_Model_Resource_Type_Abstract
  • Mage_Core_Model_Resource_Type_Db
  • Mage_Core_Model_Resource_Type_Db_Mysqli
  • Mage_Core_Model_Resource_Type_Db_Mysqli_Setup
  • Mage_Core_Model_Resource_Type_Db_Pdo_Mysql
  • Mage_Core_Model_Resource_Url_Rewrite
  • Mage_Core_Model_Resource_Url_Rewrite_Collection
  • Mage_Core_Model_Resource_Variable
  • Mage_Core_Model_Resource_Variable_Collection
  • Mage_Core_Model_Resource_Website
  • Mage_Core_Model_Resource_Website_Collection
  • Mage_Core_Model_Session
  • Mage_Core_Model_Session_Abstract
  • Mage_Core_Model_Session_Abstract_Varien
  • Mage_Core_Model_Session_Abstract_Zend
  • Mage_Core_Model_Source_Email_Variables
  • Mage_Core_Model_Store
  • Mage_Core_Model_Store_Api
  • Mage_Core_Model_Store_Api_V2
  • Mage_Core_Model_Store_Group
  • Mage_Core_Model_Template
  • Mage_Core_Model_Translate
  • Mage_Core_Model_Translate_Expr
  • Mage_Core_Model_Translate_Inline
  • Mage_Core_Model_Translate_String
  • Mage_Core_Model_Url
  • Mage_Core_Model_Url_Rewrite
  • Mage_Core_Model_Url_Validator
  • Mage_Core_Model_Variable
  • Mage_Core_Model_Variable_Config
  • Mage_Core_Model_Variable_Observer
  • Mage_Core_Model_Website
  • Mage_Page_Block_Switch
  • Mage_Page_Block_Template_Container
  • Mage_Page_Block_Template_Links
  • Mage_Page_Block_Template_Links_Block
  • Mage_Sales_Model_Quote_Address_Total_Collector

Exceptions

  • Mage_Core_Controller_Varien_Exception
  • Mage_Core_Exception
  • Mage_Core_Model_Session_Exception
  • Mage_Core_Model_Store_Exception

Functions

  • destruct
  • is_dir_writeable
  • is_empty_date
  • mageCoreErrorHandler
  • mageDebugBacktrace
  • mageDelTree
  • mageFindClassFile
  • mageParseCsv
  • mageSendErrorFooter
  • mageSendErrorHeader
  • mageUndoMagicQuotes
  • now
  • sys_get_temp_dir
  • uc_words
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Core
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Mysql4 session save handler
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Core
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Core_Model_Resource_Session implements Zend_Session_SaveHandler_Interface
 36: {
 37:     /**
 38:      * Session maximum cookie lifetime
 39:      */
 40:     const SEESION_MAX_COOKIE_LIFETIME = 3155692600;
 41: 
 42:     /**
 43:      * Session lifetime
 44:      *
 45:      * @var integer
 46:      */
 47:     protected $_lifeTime;
 48: 
 49:     /**
 50:      * Session data table name
 51:      *
 52:      * @var string
 53:      */
 54:     protected $_sessionTable;
 55: 
 56:     /**
 57:      * Database read connection
 58:      *
 59:      * @var Varien_Db_Adapter_Interface
 60:      */
 61:     protected $_read;
 62: 
 63:     /**
 64:      * Database write connection
 65:      *
 66:      * @var Varien_Db_Adapter_Interface
 67:      */
 68:     protected $_write;
 69: 
 70:     /**
 71:      * Automatic cleaning factor of expired sessions
 72:      * value zero means no automatic cleaning, one means automatic cleaning each time a session is closed, and x>1 means
 73:      * cleaning once in x calls
 74:      *
 75:      * @var int
 76:      */
 77:     protected $_automaticCleaningFactor    = 50;
 78: 
 79:     /**
 80:      * Constructor
 81:      *
 82:      */
 83:     public function __construct()
 84:     {
 85:         $resource = Mage::getSingleton('core/resource');
 86:         $this->_sessionTable = $resource->getTableName('core/session');
 87:         $this->_read         = $resource->getConnection('core_read');
 88:         $this->_write        = $resource->getConnection('core_write');
 89:     }
 90: 
 91:     /**
 92:      * Destrucor
 93:      *
 94:      */
 95:     public function __destruct()
 96:     {
 97:         session_write_close();
 98:     }
 99: 
100:     /**
101:      * Retrieve session life time
102:      *
103:      * @return int
104:      */
105:     public function getLifeTime()
106:     {
107:         if (is_null($this->_lifeTime)) {
108:             $configNode = Mage::app()->getStore()->isAdmin() ?
109:                     'admin/security/session_cookie_lifetime' : 'web/cookie/cookie_lifetime';
110:             $this->_lifeTime = (int) Mage::getStoreConfig($configNode);
111: 
112:             if ($this->_lifeTime < 60) {
113:                 $this->_lifeTime = ini_get('session.gc_maxlifetime');
114:             }
115: 
116:             if ($this->_lifeTime < 60) {
117:                 $this->_lifeTime = 3600; //one hour
118:             }
119: 
120:             if ($this->_lifeTime > self::SEESION_MAX_COOKIE_LIFETIME) {
121:                 $this->_lifeTime = self::SEESION_MAX_COOKIE_LIFETIME; // 100 years
122:             }
123:         }
124:         return $this->_lifeTime;
125:     }
126: 
127:     /**
128:      * Check DB connection
129:      *
130:      * @return bool
131:      */
132:     public function hasConnection()
133:     {
134:         if (!$this->_read) {
135:             return false;
136:         }
137:         if (!$this->_read->isTableExists($this->_sessionTable)) {
138:             return false;
139:         }
140: 
141:         return true;
142:     }
143: 
144:     /**
145:      * Setup save handler
146:      *
147:      * @return Mage_Core_Model_Resource_Session
148:      */
149:     public function setSaveHandler()
150:     {
151:         if ($this->hasConnection()) {
152:             session_set_save_handler(
153:                 array($this, 'open'),
154:                 array($this, 'close'),
155:                 array($this, 'read'),
156:                 array($this, 'write'),
157:                 array($this, 'destroy'),
158:                 array($this, 'gc')
159:             );
160:         } else {
161:             session_save_path(Mage::getBaseDir('session'));
162:         }
163:         return $this;
164:     }
165: 
166:     /**
167:      * Open session
168:      *
169:      * @param string $savePath ignored
170:      * @param string $sessName ignored
171:      * @return boolean
172:      */
173:     public function open($savePath, $sessName)
174:     {
175:         return true;
176:     }
177: 
178:     /**
179:      * Close session
180:      *
181:      * @return boolean
182:      */
183:     public function close()
184:     {
185:         $this->gc($this->getLifeTime());
186: 
187:         return true;
188:     }
189: 
190:     /**
191:      * Fetch session data
192:      *
193:      * @param string $sessId
194:      * @return string
195:      */
196:     public function read($sessId)
197:     {
198:         $select = $this->_read->select()
199:                 ->from($this->_sessionTable, array('session_data'))
200:                 ->where('session_id = :session_id')
201:                 ->where('session_expires > :session_expires');
202:         $bind = array(
203:             'session_id'      => $sessId,
204:             'session_expires' => Varien_Date::toTimestamp(true)
205:         );
206: 
207:         $data = $this->_read->fetchOne($select, $bind);
208: 
209:         return $data;
210:     }
211: 
212:     /**
213:      * Update session
214:      *
215:      * @param string $sessId
216:      * @param string $sessData
217:      * @return boolean
218:      */
219:     public function write($sessId, $sessData)
220:     {
221:         $bindValues = array(
222:             'session_id'      => $sessId
223:         );
224:         $select = $this->_write->select()
225:                 ->from($this->_sessionTable)
226:                 ->where('session_id = :session_id');
227:         $exists = $this->_read->fetchOne($select, $bindValues);
228: 
229:         $bind = array(
230:             'session_expires' => Varien_Date::toTimestamp(true) + $this->getLifeTime(),
231:             'session_data' => $sessData
232:         );
233:         if ($exists) {
234:             $where = array(
235:                 'session_id=?' => $sessId
236:             );
237:             $this->_write->update($this->_sessionTable, $bind, $where);
238:         } else {
239:             $bind['session_id'] = $sessId;
240:             $this->_write->insert($this->_sessionTable, $bind);
241:         }
242: 
243:         return true;
244:     }
245: 
246:     /**
247:      * Destroy session
248:      *
249:      * @param string $sessId
250:      * @return boolean
251:      */
252:     public function destroy($sessId)
253:     {
254:         $where = array('session_id = ?' => $sessId);
255:         $this->_write->delete($this->_sessionTable, $where);
256:         return true;
257:     }
258: 
259:     /**
260:      * Garbage collection
261:      *
262:      * @param int $sessMaxLifeTime ignored
263:      * @return boolean
264:      */
265:     public function gc($sessMaxLifeTime)
266:     {
267:         if ($this->_automaticCleaningFactor > 0) {
268:             if ($this->_automaticCleaningFactor == 1 ||
269:                 rand(1, $this->_automaticCleaningFactor) == 1) {
270:                 $where = array('session_expires < ?' => Varien_Date::toTimestamp(true));
271:                 $this->_write->delete($this->_sessionTable, $where);
272:             }
273:         }
274:         return true;
275:     }
276: }
277: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0