Hi,
today i was working on a project and i had to redirect user('vendor') to frontend from where he has logged in to the system.I already created user registration from frontend. Now i had to maintain session variable so that i can check whether the particular vendor was logged in from frontend. If so, he will be redirected to the frontend.
To store session variable i sent an ajax hit to http://www.mywebsite.com/setSessionVar.php file. As you can see that file is situated in root directory.
setSessionVar.php
<?php
require 'app/Mage.php';
Mage::app();
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
Mage::getSingleton('core/session')->setMyloginvalue('vendor');
?>
To redirect to frontend i put a check when user click on "logout" link in the dashboard area.
i.e. in file IndexController.php under
/app/code/core/Mage/Adminhtml/controllers
public function logoutAction()
{
//GET LOGIN TYPE . if vendor loggedin from frontend then it's "vendor"
$loginvalue=Mage::getSingleton('core/session')->getMyloginvalue();
if($loginvalue=="vendor")
{
Mage::getSingleton('core/session')->unsMyloginvalue();
$location=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
header("location:$location");exit;
}
//END VENDOR LOGIN CHECK
//....rest of the code here
//....
}
today i was working on a project and i had to redirect user('vendor') to frontend from where he has logged in to the system.I already created user registration from frontend. Now i had to maintain session variable so that i can check whether the particular vendor was logged in from frontend. If so, he will be redirected to the frontend.
To store session variable i sent an ajax hit to http://www.mywebsite.com/setSessionVar.php file. As you can see that file is situated in root directory.
setSessionVar.php
<?php
require 'app/Mage.php';
Mage::app();
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
Mage::getSingleton('core/session')->setMyloginvalue('vendor');
?>
To redirect to frontend i put a check when user click on "logout" link in the dashboard area.
i.e. in file IndexController.php under
/app/code/core/Mage/Adminhtml/controllers
public function logoutAction()
{
//GET LOGIN TYPE . if vendor loggedin from frontend then it's "vendor"
$loginvalue=Mage::getSingleton('core/session')->getMyloginvalue();
if($loginvalue=="vendor")
{
Mage::getSingleton('core/session')->unsMyloginvalue();
$location=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
header("location:$location");exit;
}
//END VENDOR LOGIN CHECK
//....rest of the code here
//....
}
No comments:
Post a Comment