Results 1 to 2 of 2
  1. #1
    Join Date
    May 2008
    Posts
    12
    Plugin Contributions
    0

    Default How Do I Access $_SESSION Variables in an AJAX-Called PHP Script?

    I'm developing a custom page for a client that's going to be using AJAX to call a PHP script. I'm having no luck so far in figuring out how to securely access session variables and to add new ones in the custom PHP script. Using session_start() doesn't start the existing Zen Cart session, and although I tried passing the existing session_id to the script, that's not secure and wasn't working either.

    I've seen a few posts that used some fairly complex workarounds that I prefer not to use. is there a straightforward way of getting session variables and setting new ones in a custom PHP script called via an AJAX post or get with Zen Cart that someone has had success with and is secure?

    I'm using Zen Cart 1.3.8a and JQuery's AJAX classes.

    TIA

  2. #2
    Join Date
    May 2008
    Posts
    12
    Plugin Contributions
    0

    Default Re: How Do I Access $_SESSION Variables in an AJAX-Called PHP Script?

    I finally figured this out.

    Here's the relevant code to put at the top of the outside file your AJAX call is sent to:
    Code:
    require('../includes/configure.php');
    ini_set('include_path', DIR_FS_CATALOG . PATH_SEPARATOR . ini_get('include_path'));
    chdir(DIR_FS_CATALOG);
    require_once('includes/application_top.php');

 

 

Similar Threads

  1. v153 Sharing PHP variables ($_SESSION question)
    By flyvholm in forum General Questions
    Replies: 5
    Last Post: 4 Nov 2014, 06:15 PM
  2. setting $_SESSION variables in an Observer Class
    By tcarden in forum Contribution-Writing Guidelines
    Replies: 1
    Last Post: 13 Feb 2013, 06:37 AM
  3. Passing variables without $_SESSION
    By fred_tededmondsson in forum General Questions
    Replies: 1
    Last Post: 31 Oct 2011, 07:25 PM
  4. Access the $_SESSION from a non-zen script
    By FrankDeRosa in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 12 Jun 2009, 08:11 PM
  5. Replies: 0
    Last Post: 23 Nov 2006, 08:27 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