Post by jty » Sun Aug 15, 2010 12:03 pm

I am looking for where opencart starts a session (1.4.8b)
I can see index.php does: $session = new Session();
Also in session.php and startup.php there is: session_start();

I want to add a check to see if a session has been started when a user enters any page on oc
Where do I put the code please?

I am trying to hack my way through to enable multi-store with "one cart". To do this, I want a check on each store, when the user first enters a page on any store, check to see if there is already a session
If there is no session then redirect to a chosen session setting store to get a session id. That session id is then used across all stores in the multi-store set-up. The result is that cart contents are carried through across stores.

Not being a programmer, this stuff is way above my head but I have made a bit of progress. I have it working sort-of (with minimal testing) but it's really ugly, horrible code. Perhaps I should stick to being a store owner ::)

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Skipper » Sun Aug 15, 2010 4:41 pm

With the session implementation in place, you are out of luck. But check here for a possible start: http://www.webmasterworld.com/php/3404410.htm

Newbie

Posts

Joined
Thu Jan 07, 2010 3:48 pm

Post by jty » Sun Aug 15, 2010 7:15 pm

Thanks Skipper. I have spent 3 days researching the internet to get this stupid thing :) to happen.
This thread was able to get a shared cart when the stores are sub-domains
http://forum.opencart.com/viewtopic.php ... =19#p69627
I couldn't get it working, not that I tried that hard. But my research on Google indicates that it should work for sub-domains. But I want domains not sub-domains.

I am shying away from the database method, simply because that is far too hard for me to understand

Then I found this thread on Shared SSL
http://forum.opencart.com/viewtopic.php ... 51&start=0
That thread gave me enough information to get a session id going

With the session id, I can now pass it to the other domains by implanting it in an image tag like this:
<?php echo '<img src="http://www.other_domain.com/index.php?route=common/home&sid=' . session_id() . '" width="1" height="1"/>' ?>
That appears to work but it won't work when someone has disabled third-party cookies.

Another way is to pass the session id in the url on links to the other sites. That works but then the url's have a session id in it and I don't want that to happen.

The way I am now looking into is -
when user first comes the site, check to see if there is a session. If not send to a designated site that will set a session and then redirect the user back to where they were along with the session id.
This also appears to be working. Problem is that I stuck the code in header.tpl and something tells me that this is not the right way to do things 8)

Now I don't know anymore so I will have to concede defeat :bang:
I also saw that something is happening in 1.4.9 that is going to prevent session sharing. I don't know what that means but it doesn't sound favourable for what I'm after.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am
Who is online

Users browsing this forum: No registered users and 34 guests