Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Plugin Contributions
    0

    Default reading value column in sessions table

    I wrote a script which reads $_COOKIE['zenid'] and configuration.php, looks up the value column in the sessions table and returns that value. At first glance, the content of the value column looks like a long and winding string. Rather than take the time to turn this string into the variables I need (like user name and id number), I figure a routine already exists within Zen Cart for extracting the information.

    Can somebody point me in the right direction?

  2. #2
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: reading value column in sessions table

    It's a string because you can't store arrays and objects directly into a file or the database.

    (I think) you can convert it back into an array like this:
    Code:
    $session_array = unserialize(base64_decode($stored_session_string));

    But are you sure you need the *stored* session data? Depending on what you want it might be easier to use $_SESSION[]

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: reading value column in sessions table

    What exactly are you intending to use this information for?
    .

    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.

  4. #4
    Join Date
    Aug 2008
    Posts
    2
    Plugin Contributions
    0

    Default Re: reading value column in sessions table

    Thank you. My idea was security. I am not very familiar with php's sessions and something in my mind said I should verify that the information stored locally matched the db (or file) information and the cookie information (if available).

    Example:

    Where $sessiondata is taken from the stored session.

    $stored_session_array = session_decode($sessiondata);

    I –think- I can now ensure things like $stored_sesion_array[customers_ip_address], $_SESSION[customers_ip_address], and $_SERVER['REMOTE_ADDR'] are all the same.

    If I am barking up the wrong tree, please do let me know. My goal is just to get the session information (customer ID n such) in a reliable way. Is this redundant? Do you think I should just take $_SESSION variables and trust them as good? PHP docs do claim it works fine.

 

 

Similar Threads

  1. Replies: 43
    Last Post: 21 Jan 2018, 05:55 PM
  2. 1054 Unknown column 'value' in 'field list' ... "sessions" table
    By westonm in forum Installing on a Windows Server
    Replies: 5
    Last Post: 1 Jun 2012, 10:04 PM
  3. Replies: 4
    Last Post: 14 Jan 2009, 11:45 AM
  4. table error please help: "table 'sessions' doesn't exist"
    By ebydrc in forum General Questions
    Replies: 3
    Last Post: 6 Apr 2008, 06:13 AM
  5. reading database for active sessions
    By jameswilson in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 12 Apr 2007, 03:35 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