Session and cookies are not removing in MagentoErratic cookie-related login problemExclude a specific categoryHow to Set Session Cookie Based on Query-String Param in Magentocustomer/session isLoggedIn() returns falsegetVisitorData() returns NULL on Category Page only in magento-1.9.2.2Sharing Users and Cart in website with different storeviewsSetting Magento Session CookiesSimple Observer not firing on eventMagento model not fetching dataMagento 2 : Unable to save data in Sessions with Cache enabled
Why can't RGB or bicolour LEDs produce a decent yellow?
Why was the Ancient One so hesitant to teach Dr. Strange the art of sorcery?
Will change of address affect direct deposit?
Why was this sacrifice sufficient?
Renting a house to a graduate student in my department
Exception propagation: When to catch exceptions?
Was there a contingency plan in place if Little Boy failed to detonate?
Is there a faster way to calculate Abs[z]^2 numerically?
Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?
Why do unstable nuclei form?
Is there any evidence to support the claim that the United States was "suckered into WW1" by Zionists, made by Benjamin Freedman in his 1961 speech?
How Car Rear View Mirrors Work
Is it a bad idea to replace pull-up resistors with hard pull-ups?
about the word 地図
What does it mean with the ask price is below the last price?
51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?
How to select certain lines (n, n+4, n+8, n+12...) from the file?
Is the schwa sound consistent?
What is the best way for a skeleton to impersonate human without using magic?
Why does the Earth follow an elliptical trajectory rather than a parabolic one?
How do I get past a 3-year ban from overstay with VWP?
Can you book a one-way ticket to the UK on a visa?
Why use steam instead of just hot air?
How could we transfer large amounts of energy sourced in space to Earth?
Session and cookies are not removing in Magento
Erratic cookie-related login problemExclude a specific categoryHow to Set Session Cookie Based on Query-String Param in Magentocustomer/session isLoggedIn() returns falsegetVisitorData() returns NULL on Category Page only in magento-1.9.2.2Sharing Users and Cart in website with different storeviewsSetting Magento Session CookiesSimple Observer not firing on eventMagento model not fetching dataMagento 2 : Unable to save data in Sessions with Cache enabled
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to set the cookie on user login basis and want to empty on logout. Login working perfect but logout didn't work. For that purpose I used this XML code :
<customer_logout>
<observers>
<customer_is_loggedout_observer>
<type>model</type>
<class>Easylife_Sales_Model_Observer</class>
<method>customerLogout</method>
</customer_is_loggedout_observer>
</observers>
</customer_logout>
<controller_action_predispatch>
<observers>
<customer_is_logged_in_observer>
<class>Easylife_Sales_Model_Observer</class>
<method>setHandle</method>
</customer_is_logged_in_observer>
</observers>
</controller_action_predispatch>
<sales_quote_collect_totals_before>
And PHP code is in observer :
<?php
class Easylife_Sales_Model_Observer
public function setHandle(Varien_Event_Observer $observer)
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
if($session->isLoggedIn())
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$name = 'loginuser';
$value = $customerData->getId();
Mage::getModel('core/cookie')->set($name, $value);
else if(Mage::getModel('core/cookie')->get('loginuser') > 0 )
Mage::getSingleton('customer/session')->loginById(Mage::getModel('core/cookie')->get('loginuser'));
public function customerLogout(Varien_Event_Observer $observer)
if (isset($_COOKIE['loginuser']))
unset($_COOKIE['loginuser']);
setcookie('loginuser', null, -1, '/');
Mage::getSingleton('checkout/session')->unsetAll();
$cookieName = 'loginuser';
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$session->unsetAll();
$session->clear();
//echo Mage::getModel('core/cookie')->get('loginuser');exit();
I am trying to delete the cookie value and user session on logout click. It shows message of logout successfully and redirect to home page but when reload page it logged in? What I am doing wrong? The else
condition is for multi-website where I want to logged in user when he logged in on one site.
magento-1.9 cookie logout customer-session
add a comment |
I am trying to set the cookie on user login basis and want to empty on logout. Login working perfect but logout didn't work. For that purpose I used this XML code :
<customer_logout>
<observers>
<customer_is_loggedout_observer>
<type>model</type>
<class>Easylife_Sales_Model_Observer</class>
<method>customerLogout</method>
</customer_is_loggedout_observer>
</observers>
</customer_logout>
<controller_action_predispatch>
<observers>
<customer_is_logged_in_observer>
<class>Easylife_Sales_Model_Observer</class>
<method>setHandle</method>
</customer_is_logged_in_observer>
</observers>
</controller_action_predispatch>
<sales_quote_collect_totals_before>
And PHP code is in observer :
<?php
class Easylife_Sales_Model_Observer
public function setHandle(Varien_Event_Observer $observer)
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
if($session->isLoggedIn())
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$name = 'loginuser';
$value = $customerData->getId();
Mage::getModel('core/cookie')->set($name, $value);
else if(Mage::getModel('core/cookie')->get('loginuser') > 0 )
Mage::getSingleton('customer/session')->loginById(Mage::getModel('core/cookie')->get('loginuser'));
public function customerLogout(Varien_Event_Observer $observer)
if (isset($_COOKIE['loginuser']))
unset($_COOKIE['loginuser']);
setcookie('loginuser', null, -1, '/');
Mage::getSingleton('checkout/session')->unsetAll();
$cookieName = 'loginuser';
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$session->unsetAll();
$session->clear();
//echo Mage::getModel('core/cookie')->get('loginuser');exit();
I am trying to delete the cookie value and user session on logout click. It shows message of logout successfully and redirect to home page but when reload page it logged in? What I am doing wrong? The else
condition is for multi-website where I want to logged in user when he logged in on one site.
magento-1.9 cookie logout customer-session
use Mage::getModel('core/cookie') to delete cookie as well. might be issue with domain name and http only flag issue
– Minesh Patel
Jul 11 '17 at 4:47
add a comment |
I am trying to set the cookie on user login basis and want to empty on logout. Login working perfect but logout didn't work. For that purpose I used this XML code :
<customer_logout>
<observers>
<customer_is_loggedout_observer>
<type>model</type>
<class>Easylife_Sales_Model_Observer</class>
<method>customerLogout</method>
</customer_is_loggedout_observer>
</observers>
</customer_logout>
<controller_action_predispatch>
<observers>
<customer_is_logged_in_observer>
<class>Easylife_Sales_Model_Observer</class>
<method>setHandle</method>
</customer_is_logged_in_observer>
</observers>
</controller_action_predispatch>
<sales_quote_collect_totals_before>
And PHP code is in observer :
<?php
class Easylife_Sales_Model_Observer
public function setHandle(Varien_Event_Observer $observer)
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
if($session->isLoggedIn())
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$name = 'loginuser';
$value = $customerData->getId();
Mage::getModel('core/cookie')->set($name, $value);
else if(Mage::getModel('core/cookie')->get('loginuser') > 0 )
Mage::getSingleton('customer/session')->loginById(Mage::getModel('core/cookie')->get('loginuser'));
public function customerLogout(Varien_Event_Observer $observer)
if (isset($_COOKIE['loginuser']))
unset($_COOKIE['loginuser']);
setcookie('loginuser', null, -1, '/');
Mage::getSingleton('checkout/session')->unsetAll();
$cookieName = 'loginuser';
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$session->unsetAll();
$session->clear();
//echo Mage::getModel('core/cookie')->get('loginuser');exit();
I am trying to delete the cookie value and user session on logout click. It shows message of logout successfully and redirect to home page but when reload page it logged in? What I am doing wrong? The else
condition is for multi-website where I want to logged in user when he logged in on one site.
magento-1.9 cookie logout customer-session
I am trying to set the cookie on user login basis and want to empty on logout. Login working perfect but logout didn't work. For that purpose I used this XML code :
<customer_logout>
<observers>
<customer_is_loggedout_observer>
<type>model</type>
<class>Easylife_Sales_Model_Observer</class>
<method>customerLogout</method>
</customer_is_loggedout_observer>
</observers>
</customer_logout>
<controller_action_predispatch>
<observers>
<customer_is_logged_in_observer>
<class>Easylife_Sales_Model_Observer</class>
<method>setHandle</method>
</customer_is_logged_in_observer>
</observers>
</controller_action_predispatch>
<sales_quote_collect_totals_before>
And PHP code is in observer :
<?php
class Easylife_Sales_Model_Observer
public function setHandle(Varien_Event_Observer $observer)
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
if($session->isLoggedIn())
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$name = 'loginuser';
$value = $customerData->getId();
Mage::getModel('core/cookie')->set($name, $value);
else if(Mage::getModel('core/cookie')->get('loginuser') > 0 )
Mage::getSingleton('customer/session')->loginById(Mage::getModel('core/cookie')->get('loginuser'));
public function customerLogout(Varien_Event_Observer $observer)
if (isset($_COOKIE['loginuser']))
unset($_COOKIE['loginuser']);
setcookie('loginuser', null, -1, '/');
Mage::getSingleton('checkout/session')->unsetAll();
$cookieName = 'loginuser';
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$session->unsetAll();
$session->clear();
//echo Mage::getModel('core/cookie')->get('loginuser');exit();
I am trying to delete the cookie value and user session on logout click. It shows message of logout successfully and redirect to home page but when reload page it logged in? What I am doing wrong? The else
condition is for multi-website where I want to logged in user when he logged in on one site.
magento-1.9 cookie logout customer-session
magento-1.9 cookie logout customer-session
edited Jan 15 '18 at 21:06
Greg
1,60911135
1,60911135
asked Feb 12 '15 at 7:35
AddaAdda
57214
57214
use Mage::getModel('core/cookie') to delete cookie as well. might be issue with domain name and http only flag issue
– Minesh Patel
Jul 11 '17 at 4:47
add a comment |
use Mage::getModel('core/cookie') to delete cookie as well. might be issue with domain name and http only flag issue
– Minesh Patel
Jul 11 '17 at 4:47
use Mage::getModel('core/cookie') to delete cookie as well. might be issue with domain name and http only flag issue
– Minesh Patel
Jul 11 '17 at 4:47
use Mage::getModel('core/cookie') to delete cookie as well. might be issue with domain name and http only flag issue
– Minesh Patel
Jul 11 '17 at 4:47
add a comment |
1 Answer
1
active
oldest
votes
You should use the type singleton for your observer and configure it under the frontent events:
Example for customer login
use
Namespace_Module_Model_Observer
logout
singleton
<customer_login>
<observers>
<your_unqiue_event_name1>
<class>Namespace_Module_Model_Observer</class>
<method>login</method>
<type>singleton</type>
</your_unqiue_event_name1>
</observers>
</customer_login>
</events>
Then in your observer class set/unset your custom session value
in
public function login()
.....
Mage::getSingleton('customer/session')->setMyValue($myValue);
.....
public function logout()
.....
Mage::getSingleton('customer/session')->unsMyValue();
.....
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f55489%2fsession-and-cookies-are-not-removing-in-magento%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should use the type singleton for your observer and configure it under the frontent events:
Example for customer login
use
Namespace_Module_Model_Observer
logout
singleton
<customer_login>
<observers>
<your_unqiue_event_name1>
<class>Namespace_Module_Model_Observer</class>
<method>login</method>
<type>singleton</type>
</your_unqiue_event_name1>
</observers>
</customer_login>
</events>
Then in your observer class set/unset your custom session value
in
public function login()
.....
Mage::getSingleton('customer/session')->setMyValue($myValue);
.....
public function logout()
.....
Mage::getSingleton('customer/session')->unsMyValue();
.....
add a comment |
You should use the type singleton for your observer and configure it under the frontent events:
Example for customer login
use
Namespace_Module_Model_Observer
logout
singleton
<customer_login>
<observers>
<your_unqiue_event_name1>
<class>Namespace_Module_Model_Observer</class>
<method>login</method>
<type>singleton</type>
</your_unqiue_event_name1>
</observers>
</customer_login>
</events>
Then in your observer class set/unset your custom session value
in
public function login()
.....
Mage::getSingleton('customer/session')->setMyValue($myValue);
.....
public function logout()
.....
Mage::getSingleton('customer/session')->unsMyValue();
.....
add a comment |
You should use the type singleton for your observer and configure it under the frontent events:
Example for customer login
use
Namespace_Module_Model_Observer
logout
singleton
<customer_login>
<observers>
<your_unqiue_event_name1>
<class>Namespace_Module_Model_Observer</class>
<method>login</method>
<type>singleton</type>
</your_unqiue_event_name1>
</observers>
</customer_login>
</events>
Then in your observer class set/unset your custom session value
in
public function login()
.....
Mage::getSingleton('customer/session')->setMyValue($myValue);
.....
public function logout()
.....
Mage::getSingleton('customer/session')->unsMyValue();
.....
You should use the type singleton for your observer and configure it under the frontent events:
Example for customer login
use
Namespace_Module_Model_Observer
logout
singleton
<customer_login>
<observers>
<your_unqiue_event_name1>
<class>Namespace_Module_Model_Observer</class>
<method>login</method>
<type>singleton</type>
</your_unqiue_event_name1>
</observers>
</customer_login>
</events>
Then in your observer class set/unset your custom session value
in
public function login()
.....
Mage::getSingleton('customer/session')->setMyValue($myValue);
.....
public function logout()
.....
Mage::getSingleton('customer/session')->unsMyValue();
.....
edited Nov 9 '16 at 21:36
Marius♦
169k28324695
169k28324695
answered Nov 9 '16 at 19:44
StijnStijn
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f55489%2fsession-and-cookies-are-not-removing-in-magento%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
use Mage::getModel('core/cookie') to delete cookie as well. might be issue with domain name and http only flag issue
– Minesh Patel
Jul 11 '17 at 4:47