We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37377
    • 64 Posts
    Hi,

    I'm having an issue with session updates with Ajax.

    I'm building sort of a shopping cart where products are stored in a session. I'm using JQuery to add, delete, update the session and refresh the shopping basket, but the external php page seems to create a new session in stead of updating the current one. I've echoed the session_id and both are the same.

    I use the following script to check the session's content:

    foreach($_SESSION["shopping_cart"] as $key => $value)echo "<br/>".$key."------".$value["description"];


    I also checked the session cookie settings and both are equal except the domain is different so I tried setting the params before starting the session in the external file and then it returns the right domain but it still won't work:

    session_set_cookie_params(100000,"/","www.bbt4vw.com");
    session_start();


    Does anyone know how to solve this one?

    Kind regards

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Put your ajax processing php code in a snippet and put the snippet in a resource with no template. Use the URL for that resource. Then the normal MODx processing will start off with the usual MODx session.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 37377
        • 64 Posts
        Thanks a lot, this works perfectly!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Actually, a recent post outlined a very nice AJAX framework for Revo (it would work just as well on Evo).

          https://forums.modx.com/thread/78039/tutorial-setting-up-an-ajax-framework-in-modx-revolution-2-0#dis-post-430345
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org