Post by SmallWalrus » Tue May 04, 2010 2:29 pm

Hi,

At the moment we have 3 stores set up on the same domain as follows:
http://store.domain.com/en
http://store.domain.com/fr
http://store.domain.com/de

All 3 stores share the same common backend.

Each of these stores are actually setup with a different locality and default to a different language, but the trouble comes when a user does the following:

1) visit the first store http://store.domain.com/en first
2) then visit the second store http://store.domain.com/de, at this point the store will load up with its language set to english

In fact, the second visit to the german store will share the same session as it did with the english store, because the path of the cookie is set to '/'.

Is this the ideal behaviour? Or perhaps OpenCart cookies can be set with more specific path information now to take into use cases where multiple stores can be installed in a single domain?

Newbie

Posts

Joined
Wed Mar 17, 2010 9:43 am

Post by amirhabibi » Thu May 06, 2010 3:05 am

Hi SmallWalrus,

Did you find a solution ?

Using cookies to change language isn't good for seo...

Newbie

Posts

Joined
Thu May 06, 2010 3:03 am

Post by Daniel » Thu May 06, 2010 11:10 pm

its fine for SEO!

what you want different text displayed on the same url to the search engines so they can decided which language to display?

Search engines don;t use cookies.

OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by Daniel » Thu May 06, 2010 11:12 pm

SmallWalrus wrote:Hi,

At the moment we have 3 stores set up on the same domain as follows:
http://store.domain.com/en
http://store.domain.com/fr
http://store.domain.com/de

All 3 stores share the same common backend.

Each of these stores are actually setup with a different locality and default to a different language, but the trouble comes when a user does the following:

1) visit the first store http://store.domain.com/en first
2) then visit the second store http://store.domain.com/de, at this point the store will load up with its language set to english

In fact, the second visit to the german store will share the same session as it did with the english store, because the path of the cookie is set to '/'.

Is this the ideal behaviour? Or perhaps OpenCart cookies can be set with more specific path information now to take into use cases where multiple stores can be installed in a single domain?

replace the session class with this:

Code: Select all

<?php
final class Session {
	public $data = array();
			
  	public function __construct() {		
		if (!session_id()) {
			ini_set('session.use_cookies', 'On');
			ini_set('session.use_trans_sid', 'Off');
		
			session_set_cookie_params(0, rtrim(dirname($_SERVER['PHP_SELF'])), '.' . str_replace('www.', '', $_SERVER['HTTP_HOST']));
			session_start();
		}
		
		$this->data =& $_SESSION;
	}
}
?>

OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by gila » Wed May 19, 2010 4:17 pm

hi

i replaced the session class in the \opencart\system\library\session.php file as you suggested and it works very well.

thank you. ;D

New member

Posts

Joined
Fri Jan 25, 2008 4:33 am

Post by Qphoria » Wed May 19, 2010 7:55 pm

Really? it doesn't work for me at all, at least not on my localhost dev environment. I can't login to admin or store front, and when i check my cookie, it doesn't show my path as "/shop" or domain as ".localhost", even tho the code suggests that it should.
It still shows my path as "/" and domain as "localhost" but adds the extra feature of not working.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by unicodecpp » Sat Dec 11, 2010 5:06 pm

Hi Daniel.
i have one domain with single backend and multiple fronted in my domain like:
http:///www.foroshandegan.com/poshtibanan
and
http://www.foroshandegan.com/taherkabir
and
http://www.foroshandegan.com/behbaft
and etc...
i have same problem like SmallWalrus.and i modify my backend system/library/session.php with your above code.
but problem is exists!
if you add to cart in http:///www.foroshandegan.com/poshtibanan and then add other to cart from http:///www.foroshandegan.com/taherkabir , then basket will be empty in http:///www.foroshandegan.com/poshtibanan
what is solution?
my opencart is 1.4.8
thanks

Newbie

Posts

Joined
Sat Dec 11, 2010 5:01 pm

Post by jty » Sun Dec 12, 2010 8:48 am

If I am reading this correctly, you have the opposite problem to SmallWalrus.
SmallWalrus doesn't want to share the same session whereas you want to share the session.

Where is your oc installed ? I think (I think) if you install it on the main domain root (not a subdirectory) ie http://www.foroshandegan.com/ then it should work. But I haven't tested it and I could be wrong

The easiest way I found to set-up multi-store with shared cart is to use sub-domains ie http://taherkabir.foroshandegan.com/ instead of http://www.foroshandegan.com/taherkabir
and see River's solution here: http://forum.opencart.com/viewtopic.php?f=19&t=12166
on page 1, last post by River

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by ruslyrossi » Fri May 20, 2011 5:42 pm

Hi, i have 2 stores here : oc v1.4.9.3

1) tsubamecorp.com/singapore/
2) tsubamecorp.com/malaysia/

The problem is when you login to tsubamecorp.com/singapore/admin everything is work fine...the url after login look something like this ---> tsubamecorp.com/singapore/admin/index.php?route=common/home&token=827bcf36d9c167581620f377417e8774 but when you change the folder from singapore to malaysia in url -->
tsubamecorp.com/malaysia/admin/index.php?route=common/home&token=827bcf36d9c167581620f377417e8774
you can login without put username or pass in login page for malaysia store!!!

This only happen when you try in same browser.

Any solutions??

User avatar
New member

Posts

Joined
Mon Feb 28, 2011 12:28 pm

Post by Daniel » Sun May 22, 2011 9:21 pm

ruslyrossi wrote:Hi, i have 2 stores here : oc v1.4.9.3

1) tsubamecorp.com/singapore/
2) tsubamecorp.com/malaysia/

The problem is when you login to tsubamecorp.com/singapore/admin everything is work fine...the url after login look something like this ---> tsubamecorp.com/singapore/admin/index.php?route=common/home&token=827bcf36d9c167581620f377417e8774 but when you change the folder from singapore to malaysia in url -->
tsubamecorp.com/malaysia/admin/index.php?route=common/home&token=827bcf36d9c167581620f377417e8774
you can login without put username or pass in login page for malaysia store!!!

This only happen when you try in same browser.

Any solutions??
yes because the session is shared across a domain name! use sub domains.

OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by krokodylowy3 » Mon May 28, 2012 1:41 am

Daniel wrote:its fine for SEO!
How can you say that?
Can you explain how search engine recognize and index all pages of default multilanguage OC 1.5.2 site (without subdomain per language)?

You say "Search engines don't use cookies" but in templates I see that languages and currencies are changed with POST and cookies. I suppose that was unnecesarry modification of previous versions with params in url.
Apache access log shows clearly - Googlebot visit only pages of default language.

Newbie

Posts

Joined
Fri May 18, 2012 2:39 am

Post by neetjedem » Thu Feb 07, 2013 6:33 pm

Hello,

Is this solution above also fixable to carry sessions cross domain:

Code: Select all

<?php
final class Session {
   public $data = array();
         
     public function __construct() {      
      if (!session_id()) {
         ini_set('session.use_cookies', 'On');
         ini_set('session.use_trans_sid', 'Off');
      
         session_set_cookie_params(0, rtrim(dirname($_SERVER['PHP_SELF'])), '.' . str_replace('www.', '', $_SERVER['HTTP_HOST']));
         session_start();
      }
      
      $this->data =& $_SESSION;
   }
}
?>

New member

Posts

Joined
Wed Jan 30, 2013 8:10 am

Post by aviatedman » Mon Feb 25, 2013 2:52 am

I've just gone through this whole page following everyone's instructions and mine isn't working. I have all my stores setup on subdomains and I altered the \system\library\sessions.php file as instructed as well. Have NO IDEA why jtl says it works because it CLEARLY does not!

The cart still only allows checkout for each store. And not just checkout..my customers have to LOGIN to each store too! Like seriously...WHAT is the point of multicart if sessions can't even be shared?!? (a little ridiculous) This should have been one of those common sense tasks when the entire "system" was developed.

Does anyone have any SOLID solutions for this major problem??

Newbie

Posts

Joined
Wed Sep 26, 2012 6:48 am

Post by butte » Mon Mar 25, 2013 4:46 am

Daniel's brief comments on session class and subdomains pretty well cut to the chase, in handling multistore cookies. Some people are happy. Some people may have run into variations in how their domain registrars or site hosts or both handle redirections and A records.

(1) In cases (above) where that did NOT work almost immediately, there are nuances to consider.

There remains variation in how to accomplish subdomains. On the site server itself, an effective subdomain can have its own directory at (public) root level, such as one.example.com/, two.example.com/, etc.. On the site server itself, an effective subdomain can have its own subdirectory inside a domain's directory, such as http://www.example.com/one/, http://www.example.com/two/, etc.. Some site servers "have rules" that tend to require a specific approach (which, as below, can be overcome).

In the domain registrar account (sometimes additionally on the site host(s) allowed to handle dns), there are at least two common choices:

(a) Set in dns each subdomain by name (subexample.), then, without any "A" record pointing there, redirect each to its http path (http://subexample.example.com/subexample.com) into the proper directory or subdirectory on the server (stealth so as not to show its own name, nonstealth so as to show its own name, in the browser address bar).

(b) Set in dns an "A" record for each subdomain by name (subexample.), then (without any redirection) point it directly to the server (as nnn.nnn.nnn.nnn), where inbound traffic will go to the appropriate directory or subdirectory.

In the site hosting account(s), there is at least one further common choice:

(c) Send any of that inbound traffic, via appropriately worded and nested .ht* files (.htaccess and others), to the final preferred directory or subdirectory, regardless of whether a site server "has rules" for where to nest subdomains.

(2) If NONE of that works, then a further option is to force segregation of concurrent cookies, even if the stores share a database (since a database can house several things without mixing them up), and even if a single browser is used at a time (although most customers probably won't look at sister stores at the same time). That can be done at least two ways, each presupposing that segregated cookies are understood (one way or the other) by both shared database and solitary browser.

(d) Obtain a suitably named domain for each store, and repoint each store's traffic to its own domain, using redirection (either way above) or using "A" records (above).

(e) Obtain a suitably named domain for each store, and repoint each store's traffic through that back to its actual residency subdomain, using redirection (either way above) or using "A" records (above) to its own domain.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by onlinephilately » Sat Dec 13, 2014 12:38 am

I have had a similar problem with sessions where I have my main shop in root and the test site in a subfolder /testsite.

When I set up the test site as a sub domain - testsite.domain.com - the session problem seems to be solved.

New member

Posts

Joined
Thu Jan 27, 2011 3:14 am

Post by rajivignou » Fri Jun 30, 2017 5:36 pm

Hi,

At the moment we have 3 stores set up on the same domain as follows:
http://store.domain.com/en
http://store.domain.com/fr
http://store.domain.com/de

All 3 stores share the same common backend.

Each of these stores are actually setup with a different locality and default to a different language, but the trouble comes when a user does the following:

1) visit the first store http://store.domain.com/en first
2) then visit the second store http://store.domain.com/de, at this point the store will load up with its language set to english

In fact, the second visit to the german store will share the same session as it did with the english store, because the path of the cookie is set to '/'.

Is this the ideal behaviour? Or perhaps OpenCart cookies can be set with more specific path information now to take into use cases where multiple stores can be installed in a single domain?

Newbie

Posts

Joined
Fri Jun 30, 2017 5:34 pm
Who is online

Users browsing this forum: No registered users and 16 guests