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?
Bookmarks