Need cookies help to save information

The question:

we have multi store views site.

we provide an option to change store views through dropdown here as below :

enter image description here

once we change option from dropdown, it will display selected store view.

but once we click on any other page[ menu, catalog, Product ,cms ] it will again display old store view.

but it should be in same store view until we change it manually.

Is i need to use cookies for saving ?


class Atwix_Ipstoreswitcher_Model_Observer
     * redirects customer to store view based on GeoIP
     * @param $event
     public function controllerActionPostdispatch($event)

       $geoIP = Mage::getSingleton('geoip/country');
        $cnCode =  $geoIP->getCountry();
       // echo $cnCode;
       // echo $cnCode='IN';
            switch ($cnCode) {
                case "US": {
                case "IN": {
                case "CA": {
                case "UK": {

                case "AU": {




<?php if(count($this->getStores())>1): ?>
$lis = "";
$selCurrency = $this->__('Currency');
foreach ($this->getStores() as $_lang):
    if($_lang->getId() == $this->getCurrentStoreId()){
        //This line will show SYMBOL only
        //$selCurrency = "[".Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol()."]";

        //This line will show FULLNAME
        $selCurrency = '  '.$this->escapeHtml($_lang->getName());
    $lis .= '<li><a href="'.$_lang->getCurrentUrl().'" rel="nofollow noreferrer noopener">'.$this->escapeHtml($_lang->getName()).'</a></li>';
<div class="form-language">
    <ul id="select-language" title="<?php echo $this->__('Currency') ?>" class="dropDownMenu">
        <li><a href=""><?php echo $selCurrency ?></a>
            <?php echo $lis ?>
<?php endif; ?>

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

First of all, looks like your observer.php sets the store always to “India”, is that correct?

About your question, the best option is to have a separate URL for each store view, which could be a subdirectory (, subdomain ( or even a new domain (

This link explains more about this topic.

After choosing your approach, you need to:

  1. Create the Store View in Magento admin panel
  2. Create the new address (subdomain, subdirectory or new domain) in you server and copy the files index.php and .htaccess to that new folder.
  3. Edit the bottom of index.php in the line: Mage::run($mageRunCode, $mageRunType); to set your RunCode (code of the store defined in Magento admin) and RunType (store or website).

  4. Go to System > Configuration > General > Web and make sure that you are editing the right Store View (you can change it in the upper left corner under “Current Configuration Scope”).

  5. Under the tabs Unsecure and Secure, change the Base URL field to match your new store view URL.

After that, you need to create symlinks for the Magento files, this will allow you to keep navigating in the same store view.

Use SSH to access the root folder of your new storeview
/home/example/ and execute this:

ln -s /home/example/ app
ln -s /home/example/ includes 
ln -s /home/example/ js 
ln -s /home/example/ lib 
ln -s /home/example/ media 
ln -s /home/example/ skin 
ln -s /home/example/ var

This should solve your problem.

If you want to read more:

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment