Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new frontend cookie name (session namespace). Refs #990 #991

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Controller/Front/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Mage_Core_Controller_Front_Action extends Mage_Core_Controller_Varien_Acti
/**
* Session namespace to refer in other places
*/
const SESSION_NAMESPACE = 'frontend';
const SESSION_NAMESPACE = 'om_frontend';

/**
* Add secret key to url config path
Expand Down
25 changes: 24 additions & 1 deletion app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,18 @@ public function start($sessionName=null)

if (!empty($sessionName)) {
$this->setSessionName($sessionName);
}

// Migrate old cookie from 'frontend'
if ($sessionName === \Mage_Core_Controller_Front_Action::SESSION_NAMESPACE
&& $cookie->get('frontend')
&& ! $cookie->get(\Mage_Core_Controller_Front_Action::SESSION_NAMESPACE)
) {
$frontendValue = $cookie->get('frontend');
$_COOKIE[\Mage_Core_Controller_Front_Action::SESSION_NAMESPACE] = $frontendValue;
$cookie->set(Mage_Core_Controller_Front_Action::SESSION_NAMESPACE, $frontendValue);
$cookie->delete('frontend');
}
}
// potential custom logic for session id (ex. switching between hosts)
$this->setSessionId();

Expand All @@ -141,6 +151,19 @@ public function start($sessionName=null)
$secureCookieName = $sessionName . '_cid';
if (isset($_SESSION[self::SECURE_COOKIE_CHECK_KEY])) {
$cookieValue = $cookie->get($secureCookieName);

// Migrate old cookie from 'frontend'
if ( ! $cookieValue
&& $sessionName === \Mage_Core_Controller_Front_Action::SESSION_NAMESPACE
&& $cookie->get('frontend_cid')
&& ! $cookie->get($secureCookieName)
) {
$frontendValue = $cookie->get('frontend_cid');
$_COOKIE[$secureCookieName] = $frontendValue;
$cookie->set($secureCookieName, $frontendValue);
$cookie->delete('frontend_cid');
}

if (!is_string($cookieValue) || $_SESSION[self::SECURE_COOKIE_CHECK_KEY] !== md5($cookieValue)) {
session_regenerate_id(false);
$sessionHosts = $this->getSessionHosts();
Expand Down