Exemple #1
0
 /**
  * @param string $saveMethod
  * @param string $iniValue
  * @dataProvider sessionSaveMethodDataProvider
  */
 public function testSessionSaveMethod($saveMethod, $iniValue)
 {
     $this->markTestIncomplete('Bug MAGE-5487');
     // depending on configuration some values cannot be set as default save session handlers.
     // in such cases warnings will be generated by php and test will fail
     $origErrorRep = error_reporting(E_ALL ^ E_WARNING);
     $origSessionHandler = ini_set('session.save_handler', $iniValue);
     if ($iniValue && ini_get('session.save_handler') != $iniValue) {
         ini_set('session.save_handler', $origSessionHandler);
         error_reporting($origErrorRep);
         $this->markTestSkipped("Can't  set '{$iniValue}' as session save handler");
     }
     ini_set('session.save_handler', $origSessionHandler);
     Mage::getConfig()->setNode(Mage_Core_Model_Session_Abstract::XML_NODE_SESSION_SAVE, $saveMethod);
     /**
      * @var Mage_Core_Model_Session_Abstract_Varien
      */
     $model = new Mage_Core_Model_Session_Abstract();
     //There is no any possibility to determine whether session already started or not in php before 5.4
     $model->setSkipEmptySessionCheck(true);
     $model->start();
     if ($iniValue) {
         $this->assertEquals(ini_get('session.save_handler'), $iniValue);
     }
     ini_set('session.save_handler', $origSessionHandler);
     error_reporting($origErrorRep);
 }
 /**
  * {@inheritDoc}
  */
 public function regenerate($destroy = false)
 {
     if (self::$sessionIdRegenerated) {
         return;
     }
     $this->session->regenerateSessionId();
     self::$sessionIdRegenerated = true;
 }
 /**
  * Try to get the id of the customer
  * 
  * @return int|null
  */
 public function getCustomerId()
 {
     if (class_exists('Mage')) {
         return Mage::getSingleton('customer/session')->getCustomer()->getId();
     }
     return parent::getCustomerId();
 }
Exemple #4
0
 public function setSessionId($id = null)
 {
     if (!empty($this->_sid)) {
         $id = $this->_sid;
     }
     return parent::setSessionId($id);
 }
 /**
  * Stores a post's comment data in the session in case of error
  *
  * @param Fishpig_Wordpress_Model_Post $post
  * @param string $author
  * @param string $email 
  * @param string $url
  * @param string $comment
  */
 public function setPostCommentData($post, $author, $email, $url, $comment)
 {
     if (is_object($post)) {
         $token = 'post_comment_data_' . $post->getId();
         $data = new Varien_Object(array('author' => $author, 'email' => $email, 'url' => $url, 'comment' => $comment));
         return parent::setData($token, $data);
     }
 }
Exemple #6
0
 /**
  * Unset all data associated with object
  */
 public function unsetAll()
 {
     parent::unsetAll();
     $this->_quoteId = null;
     $this->_response = null;
     $this->_redirectMessage = null;
     $this->_redirectTitle = null;
 }
Exemple #7
0
 public function addMessage(Mage_Core_Model_Message_Abstract $message)
 {
     $message->setIdentifier(uniqid() . '|' . $this->_now);
     return parent::addMessage($message);
 }
 /**
  * Remove visitor-segment relation for specified website
  *
  * @param Mage_Core_Model_Session_Abstract $visitorSession
  * @param int $websiteId
  * @param array $segmentIds
  * @return Enterprise_CustomerSegment_Model_Customer
  */
 public function removeVisitorFromWebsiteSegments($visitorSession, $websiteId, $segmentIds)
 {
     $visitorCustomerSegmentIds = $visitorSession->getCustomerSegmentIds();
     if (!is_array($visitorCustomerSegmentIds)) {
         $visitorCustomerSegmentIds = array();
     }
     if (isset($visitorCustomerSegmentIds[$websiteId]) && is_array($visitorCustomerSegmentIds[$websiteId])) {
         $segmentsIdsForWebsite = $visitorCustomerSegmentIds[$websiteId];
         if (!empty($segmentIds)) {
             $segmentsIdsForWebsite = array_diff($segmentsIdsForWebsite, $segmentIds);
         }
         $visitorCustomerSegmentIds[$websiteId] = $segmentsIdsForWebsite;
     }
     $visitorSession->setCustomerSegmentIds($visitorCustomerSegmentIds);
     return $this;
 }
Exemple #9
0
 /**
  * Get ecrypted session identifuer
  * No reason use crypt key for session id encryption
  * we can use session identifier as is
  *
  * @return string
  */
 public function getEncryptedSessionId()
 {
     if (!self::$_encryptedSessionId) {
         //            $helper = Mage::helper('Mage_Core_Helper_Data');
         //            if (!$helper) {
         //                return $this;
         //            }
         //            self::$_encryptedSessionId = $helper->encrypt($this->getSessionId());
         self::$_encryptedSessionId = $this->getSessionId();
     }
     return self::$_encryptedSessionId;
 }
Exemple #10
0
 public function testGetSessionSavePath()
 {
     $this->assertEquals(Mage::getBaseDir('session'), $this->_model->getSessionSavePath());
 }
 /**
  * Class constructor. Initialize Rede ClickPag session namespace
  */
 public function __construct()
 {
     parent::__construct();
     $this->init('rede_clickpag');
 }
Exemple #12
0
 /**
  * Unset all data associated with object
  */
 public function unsetAll()
 {
     parent::unsetAll();
     $this->_quote = null;
 }
Exemple #13
0
 /**
  * Get encrypted session identifier.
  * No reason use crypt key for session id encryption, we can use session identifier as is.
  *
  * @return string
  */
 public function getEncryptedSessionId()
 {
     if (!self::$_encryptedSessionId) {
         self::$_encryptedSessionId = $this->getSessionId();
     }
     return self::$_encryptedSessionId;
 }
Exemple #14
0
 /**
  * Reset core session hosts after reseting session ID
  *
  * @return Mage_Customer_Model_Session
  */
 public function renewSession()
 {
     parent::renewSession();
     $this->_cleanHosts();
     return $this;
 }
Exemple #15
0
 public function unsetAll()
 {
     parent::unsetAll();
     $this->_collections = null;
 }
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require 'app/Mage.php';
Mage::app();
$test = in_array('--test', $argv);
$coreSession = new Mage_Core_Model_Session_Abstract();
$redisSession = new Cm_RedisSession_Model_Session();
$sessionPath = $coreSession->getSessionSavePath();
if (!is_readable($sessionPath) || !($dir = opendir($sessionPath))) {
    die("The session save path is not readable: {$sessionPath}\n");
}
if (!$redisSession->hasConnection()) {
    die("Could not connect to redis server, please check your configuration.\n");
}
$sessionLifetime = max(Mage::getStoreConfig('admin/security/session_cookie_lifetime'), Mage::getStoreConfig('web/cookie/cookie_lifetime'), 3600);
if (!in_array('-y', $argv)) {
    $redisConfig = Mage::getConfig()->getNode('global/redis_session');
    $redisConnection = $redisConfig->descend('host') . ':' . $redisConfig->descend('port') . '/' . $redisConfig->descend('db');
    $input = readline("Migrate sessions from {$sessionPath} to {$redisConnection} with {$sessionLifetime} second lifetime? (y|n) ");
    if ($input != 'y') {
        die("Aborted.\n");
 /**
  * Get ecrypted session identifuer
  * No reason use crypt key for session id encryption
  * we can use session identifier as is
  *
  * @return string
  */
 public function getEncryptedSessionId()
 {
     if (!self::$_encryptedSessionId) {
         //            $helper = AO::helper('core');
         //            if (!$helper) {
         //                return $this;
         //            }
         //            self::$_encryptedSessionId = $helper->encrypt($this->getSessionId());
         self::$_encryptedSessionId = $this->getSessionId();
     }
     return self::$_encryptedSessionId;
 }
Exemple #18
0
 /**
  * Reset core session hosts after reseting session ID
  *
  * @return Mage_Customer_Model_Session
  */
 public function renewSession()
 {
     parent::renewSession();
     Mage::getSingleton('core/session')->unsSessionHosts();
     return $this;
 }
Exemple #19
0
 public function getEncryptedSessionId()
 {
     if (!self::$_encryptedSessionId) {
         $helper = Mage::helper('core');
         if (!$helper) {
             return $this;
         }
         self::$_encryptedSessionId = $helper->encrypt($this->getSessionId());
     }
     return self::$_encryptedSessionId;
 }
Exemple #20
0
 public function unsetAll()
 {
     parent::unsetAll();
 }
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->init(HooshMarketing_Marketo_Model_Lead::SESSION_NAMESPACE);
 }
 public function start($sessionName = null)
 {
     parent::start($sessionName = null);
     $this->sessionIds[] = $this->getSessionId();
     return $this;
 }
Exemple #23
0
 /**
  * Reset core session hosts after reseting session ID
  *
  * @return Mage_Customer_Model_Session
  */
 public function renewSession()
 {
     parent::renewSession();
     Mage::getSingleton('Mage_Core_Model_Session')->unsSessionHosts();
     return $this;
 }
 /**
  * Pull out information from session whether there is currently the first page after log in
  *
  * The idea is to set this value on login(), then redirect happens,
  * after that on next request the value is grabbed once the session is initialized
  * Since the session is used as a singleton, the value will be in $_isFirstPageAfterLogin until the end of request,
  * unless it is reset intentionally from somewhere
  *
  * @param string $namespace
  * @param string $sessionName
  * @return Mage_Admin_Model_Session
  * @see self::login()
  */
 public function init($namespace, $sessionName = null)
 {
     parent::init($namespace, $sessionName);
     $this->isFirstPageAfterLogin();
     return $this;
 }
 /**
  * Return all currently registered messages from block and specified session.
  *
  * @param Mage_Core_Model_Session_Abstract $session
  * @return array
  */
 protected function _getMessages(Mage_Core_Model_Session_Abstract $session)
 {
     $messages = array();
     $type = 'error';
     // If the message block already has been instantiated, get those messages
     /** @var $block Mage_Core_Block_Messages */
     if ($block = Mage::app()->getLayout()->getBlock('messages')) {
         $messages = array_merge($messages, $block->getMessages($type));
     }
     // Merge in the messages from the session
     $messages = array_merge($messages, $session->getMessages()->getItems($type));
     return $messages;
 }