If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / accessing cart from pages outside of zencart DIR

accessing cart from pages outside of zencart DIR

Locked

Started by orzel on 20 Jul 2009, 7:38 PM · Views: 928

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
20 Jul 2009, 7:38 PM
#1
orzel avatar

orzel

New Zenner

Join Date:
Jul 2009
Posts:
2
Plugin Contributions:
0

Post #1 by orzel

I have zencart. 1.3.8 running on Linux with php in cgi.

How do I access the zen cart $_SESSION['cart'] from pages that are not within my store?

I have my zencart at:

mydomain.com/store

I have another application at:

mydomain.com/myapp

Within myapp I have an AJAX call to a php file that tries to read the cart parameters $_SESSION['cart']->show_total() (as an example)

One thing I noticed is that the session id is lost outside of mydomain/store. I thought a session id was good across the whole domain since init_sessions.php has:

session_set_cookie_params(0, '/', (zen_not_null($current_domain) ? $current_domain : ''));

From mydomain/myapp I have an ajax call to ajax.php file I tried:

<?php require('../includes/application_top.php'); echo $_SESSION['cart']->show_total(); ?>

I tried this file in a few locations within the zencart directory (store/pub) and within myapp directory and changed the location of application_top.php and it didn't echo anything back through my ajax call.

I would think there would be a simple way to access the cart info from outside of the zencart directory from within the same domain?

Thanks,
Mark

20 Jul 2009, 7:45 PM
#2
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Post #2 by afo

Zen Cart isn't designed to be the back end of a site. It's designed to be the site. If you leave the Zen Cart portion of the site, you'll lose the session and (most likely) anything that was in the cart.

Mary Ellen
I came; I saw; I Zenned
Taking over the world... one website at a time
Make sure brain is engaged before putting mouth in gear... or fingers to keyboard.

Holzheimer
Fan Odyssey

20 Jul 2009, 8:11 PM
#3
orzel avatar

orzel

New Zenner

Join Date:
Jul 2009
Posts:
2
Plugin Contributions:
0

Post #3 by orzel

I understand that zencart is meant to be the site. But it also seems to have a lot of flexibility. I have an application that can not be plugged into a zencart page, so it needs to run on the side of it.

Why is the session lost when you leave the zencart directory?

I thought you could set a session to be saved across an entire domain with session_set_cookie_params?

I looked at the initSystem tutorial with regards to creating classes. Could I create a class that extends from the $_SESSION['cart'] and then use that class outside of the zencart directory.

Thanks,
Mark

20 Jul 2009, 8:58 PM
#4
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,950
Plugin Contributions:
3

Post #4 by wilt

You need to start a session, to access session variables.

Note also that in order to access a Zen Cart session you would have to start the session with a name of zenid.

This assume that sessions are being stored in a cookie. If they are not then you would need to pass the zenid value to whatever script you were using and set it to the session using session_id()

see

http://us2.php.net/manual/en/function.session-id.php

http://us2.php.net/manual/en/function.session-start.php

http://us2.php.net/manual/en/function.session-name.php