Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2006
    Posts
    2
    Plugin Contributions
    0

    Default Accessing user login & session info from outside zencart

    I am trying to make it possible for pages on my site that aren't in my zencart system to be able to access Zencart session information.

    For example, my Zencart store is at MYURL/store. I would like to be able to have my MYURL/index.php (or some other file in another directory) to say something like "Logged in as USERNAME", if the user is logged into the store. Also i will want to use the zen_href_link and other such functions.

    including 'application_top.php' in a file that is not in the zencart directory leads to the expected path errors. so i created outside.php in the zencart root directory, which just reads to see if someone is logged in:

    Code:
    <?php
        $curdir = getcwd();
        if (chdir(dirname(__FILE__))) {
    		require('includes/application_top.php');
    		if (isset($_SESSION) && isset($_SESSION['customer_id'])) {
    			?>
    			Logged in as <?= zen_output_string_protected($_SESSION['customer_first_name']); ?><br>
    			<a href="<?= zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>">Log Off</a>
    			<a href="<?= zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>">Account Manager</a>
    			<?php
    		} else {
    			?>
    			Not logged in<br>
    			<a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>">Log In</a>
    			<?php
    		}
    		chdir($curdir);
    	}
    ?>
    opening this file in a browser works as expected. however, if i try to require that file from outside the zencart directory, i get this error:
    Fatal error: Call to a member function on a non-object in includes\classes\db\mysql\query_factory.php on line 103

    obviously i don't want to go changing things in the zencart core stuff, since this error is just because i am doing something outside the lines.

    is there an easier way to access this login info? maybe instead of loading application_top.php, would loading one of the sub-pages work?

  2. #2
    Join Date
    Jun 2005
    Posts
    89
    Plugin Contributions
    0

    Default Re: Accessing user login & session info from outside zencart

    Any progress on this?

    I succeeded in doing this for 1.2.6 Zen Cart, but things seem to have changed quite a bit in 1.3.

    All i did previously was take the relevant parts of application_top.php i needed to access from outside the zen directory and create another php file - as MAV describes above.
    These carried the session etc and allowed me to use the login session to provide my account links, or if there was no session, to provide a login link which redirected back to whichever static page was used once logged in.

    Cant achieve this on 1.3 so far. Any tips?

  3. #3
    Join Date
    Jun 2005
    Posts
    89
    Plugin Contributions
    0

    Default Re: Accessing user login & session info from outside zencart

    anyone help on this?

  4. #4
    Join Date
    Jan 2008
    Posts
    5
    Plugin Contributions
    0

    Default Re: Accessing user login & session info from outside zencart

    How do you find the variables such as "first name" to include in this script?

    E.g. $_SESSION['customer_first_name']

    I want to include street address and city as well...

  5. #5
    Join Date
    Oct 2007
    Location
    France & Luxembourg
    Posts
    37
    Plugin Contributions
    0

    help question Re: Accessing user login & session info from outside zencart

    in my case i have the same need, and have similar problems.

    for the payment process to complete
    the response is stored and the customer redirected

    however, When the gateway sends back success/fail messages,

    the payment process doesn´t continue,
    instead sends the gateway to a session expired page.


    requiring / including application top results in errors in my case as well.

  6. #6
    Join Date
    Dec 2007
    Posts
    1
    Plugin Contributions
    0

    Default Re: Accessing user login & session info from outside zencart

    I am trying to make it possible for pages on my site that aren't in my zencart system to be able to access Zencart session information.
    I am looking for the same answer. This is getting to be a real pain in the back side for something that should be so simple.

  7. #7
    Join Date
    Feb 2007
    Location
    San Luis Obispo
    Posts
    10
    Plugin Contributions
    0

    Idea or Suggestion Re: Accessing user login & session info from outside zencart

    The session cookie is zenid
    if you store the session in the db then you can query for the session sesskey = '$_COOKIE['zenid']'

    You then need to unserialize the value.

    Totally enabled us to create a single sign on solution for site.

 

 

Similar Threads

  1. Reading session variables outside of the zencart directory
    By refreshmentshop in forum General Questions
    Replies: 5
    Last Post: 22 Sep 2009, 09:53 AM
  2. accessing cart from pages outside of zencart DIR
    By orzel in forum General Questions
    Replies: 3
    Last Post: 20 Jul 2009, 09:58 PM
  3. A pretty weird problem while accessing session outside of zen
    By yellow1912 in forum Contribution-Writing Guidelines
    Replies: 2
    Last Post: 1 Jul 2009, 02:44 AM
  4. Replies: 12
    Last Post: 24 Jul 2008, 10:47 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