Hi folks,
Anyone have any luck getting jCart and PW to play nicely together? I can't for the life of me figure it out.
I know that it's a session_start issue, as everything works fine if I bootstrap PW after including jCart, in a normal PHP page. How can achieve the same effect within a template?
I've tried including jCart in index.php, config.php, and Process.php, but jCart still can't seem to retain its session data.
Thanks for your help!
-evan
jCart + Processwire (session_start issue)
Started by evan, Jun 24 2012 09:10 PM
3 replies to this topic
#3
Posted 25 June 2012 - 12:18 PM
OK, I made a little headway. jCart appears to work fine if I comment out @session_start() in the __construct() of the Session class, and let jCart declare it. However this breaks the PW login, as it reports that the login is forged.
The problem seems to be where session_start() is declared, and when the jCart object is defined. Because the object declaration for jCart is happening after session_start(), jCart can't create the object and store it in $_SESSION.
So my new question is, where is a good place to define an object before PW starts the session, and that's accessible to templates?
Thanks for bearing with me, folks!
The problem seems to be where session_start() is declared, and when the jCart object is defined. Because the object declaration for jCart is happening after session_start(), jCart can't create the object and store it in $_SESSION.
So my new question is, where is a good place to define an object before PW starts the session, and that's accessible to templates?
Thanks for bearing with me, folks!
#4
Posted 25 June 2012 - 01:10 PM
All right, looks like it was my mistake. Including the jCart PHP into config.php does work, if you move the initialization code to the head of your template, which is this bit:
...and also remove jCart's session_start.
Sometimes you just gotta take a break!
// Initialize jcart after session start
$jcart = $_SESSION['jcart'];
if(!is_object($jcart)) {
$jcart = $_SESSION['jcart'] = new Jcart();
}
...and also remove jCart's session_start.
Sometimes you just gotta take a break!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













