Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009
    Location
    Charlottesville, VA
    Posts
    51
    Plugin Contributions
    0

    Default Access the $_SESSION from a non-zen script

    My client wanted to be able to deliver pdf reports to customer registered in ZC, so I created an admin screen that allows them to upload the documents to the server and associate them with an account. This is all working great. Problem is, the customer wants the files to be confidential, so I cooked up a simple script to read the files from a publicly inaccessible folder. It works nicely, except that I need for this scrip to be able to read $_SESSION['customer_id'] from the session variables so that I can do a quick check in the database that the requested report belongs to the customer. I don't want to pass the session value by $_GET as a link parameter so that links can't be forged - I want this script to read the value right out of the session. This will also prevent non-logged in users from getting anywhere.

    So, after that long description, how can I get access to the Zen session? I have been able to get the query factory object by including config.php, init_database.php and class.base.php. Can I include something else to initiate the zen cart session?

    Thanks,
    Frank

  2. #2
    Join Date
    Jan 2009
    Location
    Charlottesville, VA
    Posts
    51
    Plugin Contributions
    0

    Default Re: Access the $_SESSION from a non-zen script

    Oh, hmm. How embarrassing.

    As soon as I posted this I started to remember about application_top.php. In my "admin" area, which is in a folder, I couldn't require application_top because the paths are all messed up. application_top wants to be called from the base ZC folder.

    So then I realized while my other stuff needs to be in that folder, my file reading script does not. So I stuck in the base folder, required application_top, and boom, it worked. I don't even need to fiddle with .htaccess files.

    So, um, I hope this is helpful to anybody else who needs to score the session, or the query factory object, or use other API features in a standalone script.

    Wait a sec... I could have used the chdir command...? Sigh, *facepalm*. Is it Friday over yet?

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Access the $_SESSION from a non-zen script

    Thanks for the update on the solution that you used ... it can be very handy eh?

    And just think how many folks you helped by laying yourself bare ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Get $_SESSION['cart'] data on a non-zen page
    By djdavedawson in forum General Questions
    Replies: 6
    Last Post: 7 Feb 2013, 04:07 PM
  2. Replies: 1
    Last Post: 21 Apr 2010, 06:37 PM
  3. Access the $_SESSION from a non-zen folder
    By drbyday in forum General Questions
    Replies: 4
    Last Post: 19 Sep 2009, 04:39 AM
  4. How do I set the language from a non-zen-cart page?
    By jdl in forum General Questions
    Replies: 1
    Last Post: 28 May 2008, 06:50 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