Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    8,956
    Plugin Contributions
    71

    Default [Done v155b] AJAX: Session-variable changes not saved

    I'm in the process of updating the One-Page Checkout plugin to handle shipping selections that become invalid after the first page entry.

    I've got updates to the plugin's AJAX handler to unset the session's shipping selection if the customer's current selection has somehow gone invalid, but the variable's "unset" was never kicking in.

    FWIW, I'm using the following construct for that variable-removal since the session-variable is being accessed within a function:
    Code:
    unset ($GLOBALS[_SESSION]['shipping']);
    I traced the issue down to the fact that the default ajax.php handler (ZC 1.5.5a) doesn't end with the inclusion of the application_bottom.php script (the one that closes/saves the session on exit).

    When I updated /ajax.php, adding the following line at the end, the session-related variables were properly saved:
    Code:
    require ('includes/application_bottom.php');

  2. #2
    Join Date
    Jan 2004
    Posts
    65,286
    Blog Entries
    7
    Plugin Contributions
    227

    Default Re: AJAX: Session-variable changes not saved

    Good point. Feel free to submit a PR for application_bottom


    Shouldn't your unset() be referencing $_SESSION instead of _SESSION ?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    8,956
    Plugin Contributions
    71

    Default Re: AJAX: Session-variable changes not saved

    Er, it would actually be a PR for /ajax.php, but I'll get to it.

    FWIW, unsetting global variables within a function (so the variable is out-of-scope) requires the construct that I posted; using the construct
    Code:
    unset ($_SESSION['shipping']);
    within a function simply unsets the function's local copy of that super-global variable.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    8,956
    Plugin Contributions
    71

    Default Re: AJAX: Session-variable changes not saved

    Quote Originally Posted by lat9 View Post
    Er, it would actually be a PR for /ajax.php, but I'll get to it.

    FWIW, unsetting global variables within a function (so the variable is out-of-scope) requires the construct that I posted; using the construct
    Code:
    unset ($_SESSION['shipping']);
    within a function simply unsets the function's local copy of that super-global variable.
    Ref: PHP unset function documentation

  5. #5
    Join Date
    Jan 2004
    Posts
    65,286
    Blog Entries
    7
    Plugin Contributions
    227

    Default Re: AJAX: Session-variable changes not saved

    Ya, but superglobals like $_SESSION, $_POST, $_GET, etc are always in-scope, both inside and outside a function.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    8,956
    Plugin Contributions
    71

    Default Re: AJAX: Session-variable changes not saved

    Darn it, I thought that I'd seen such an issue in the past ... but you're (as always) correct -- no need for the jumping-through-hoops!

 

 

Similar Threads

  1. Replies: 3
    Last Post: 15 Jul 2016, 03:40 AM
  2. v154 Naming a global variable the same as a SESSION, GET or POST variable
    By torvista in forum General Questions
    Replies: 5
    Last Post: 6 Dec 2015, 11:11 AM
  3. [Done v1.3.9d] contact us message not saved
    By tony_sar in forum Bug Reports
    Replies: 6
    Last Post: 31 Jul 2010, 08:10 PM
  4. Changes not saved
    By Jim Kailen in forum Basic Configuration
    Replies: 4
    Last Post: 28 Apr 2010, 06:15 PM
  5. Session Not being saved
    By Czarest in forum General Questions
    Replies: 29
    Last Post: 24 May 2006, 02:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR