Im new to modx so I dont know if am doing it wrong. I do a snippet call [[!shopSession]] in that snippet i include a file so I can instantiate a class. That class is a Cart class and I save it in to $_SESSION['cart'];. I add items to the cart with $_POST. If post is set ad product.
In firefox everything works fine but in chrome it adds to the cart object. Then when i go to a new page the cart drops the item.
-
MODX Staff
- 10,725 Posts
Sounds like your cookie configuration might be incorrect. Do you have anything set as session_cookie_domain? Also, make sure you are not flip-flopping between the www and non-www version of your domain, as they will always have separate cookies unless you configure session_cookie_domain for all subdomains of your domain.
It works like a charm outside MODx. I only use SESSION so I dont set anything else then my session variable. The thing I dont understand i that it works under firefox and ie but not under chrome. After I have do $_SESSION['cart'] = serialize($cart); i print out $_SESSION['cart'] and the output is correct but if a go to a other page the value disappear.
Dont understand anything.
I can add that it dosent drop the whole session just take back the one from before you added the product.
-
MODX Staff
- 10,725 Posts
Are you using the cache_db setting by any chance? What release of MODX?
Using MODX Revolution 2.1.1-pl.
Dont know if I use cache_db. How do I check that?
I can add a product to the cart if I click add many times. The page reload each time I add.
After hours och googling I found that people had problems with google chrome and friendly urls.
If I turn it off it works but i want to use it. So dose anyone have any idea to solve it?
opengeek I really appreciate you trying to help me.
-
MODX Staff
- 10,725 Posts
Are you doing a redirect after setting the session variables? If so, you need to call session_write_close() after setting the session variables and before calling the redirect.