I have a custom module, which basically adds social media login in magento. However I am facing an issue with core/session
which I dont know how to resolve.
I am adding my custom blocks in customer login page via my own layout xml file. Every block is loading successfully. One of my cusotm block is setting a variable in core/session
through it's _construct()
method as like this.
File : app\code\local\Mynamespace/Mymodule/Block/Entity/Someblock.php
<?php
class Mynamespace_Mymodule_Block_Entity_Someblock extends Mage_Core_Block_Template
{
protected function _construct() {
parent::_construct();
// CSRF protection
$csrf = md5(uniqid(rand(), true));
Mage::getSingleton('core/session')->setGoogleCsrf($csrf);
$this->client->setState($csrf);
}
}
I ensured that, session variable is set when the page loads. Now in the next process/request, I need to validate google_csrf
variable that is set in core/session
. But the problem is Mage_Core_Model_Session
appears to be empty in the next process. Suppose I need to validate session during the request of url www.domain.com/frontname/google/connect
, then I checked core/session
in the corresponding controller file like this.
File : app\code\local\Mynamespace/Mymodule/controllers/GoogleController.php
public function connectAction()
{
print_r(Mage::getSingleton('core/session'));die();
}
But it outputs Mage_Core_Model_Session
with no variable set in it. Why it happens like this?
More info: actually the block in question is used to show google button in frontend. When click on that button, it will force user to authenticate him with google account. I am checking core/session
in the controller that processes the redirect url
. I am getting the response successfully. But core/session
that set before this action seems empty.
You have any thoughts about it ? Let me know.