cordoval Posted September 11, 2008 Posted September 11, 2008 Hi, I am trying to find out that the user is logged in. The problem is that I am doing this outside the catalog directory. this is a snippet that never works, so it will give you an idea: <?php // if the customer is not logged on, show sign in and if it is logged on then show log off if (!isset($_SESSION[session_name()])) { //show sign in button echo "sign in<br>"; echo session_name(); echo $HTTP_COOKIE_VARS[session_name()]; $cparams = session_get_cookie_params(); echo $cparams['path']; echo $cparams['domain']; } else { // show log off button echo "log off<br>"; echo session_name(); echo $HTTP_COOKIE_VARS[session_name()]; $cparams = session_get_cookie_params(); echo $cparams['path']; echo $cparams['domain']; } ?> How can I do this? any hints? Encouragements, please email directly at [email protected] if you need to, thanks.
cordoval Posted September 11, 2008 Author Posted September 11, 2008 I have found that the function to find out if there is user logged in is: <?php if (tep_session_is_registered('customer_id')) { echo "01"; } else { echo "3"; } ?> This is code above is inside a check_status.php file inside the catalog directory. The problem that I have now is that when I call this file using cURL php functions then the contents/response above (01 or 3) are gotten on the server side and that does not have any customer_id related to it so it gives the wrong answer. I would like to know how can I request this check_status.php within a page outside the catalog directory without being on the server side. I thought in using javascript but maybe there is a better option. Many thanks,
arietis Posted September 12, 2008 Posted September 12, 2008 how can I request this check_status.php within a page outside the catalog directory without being on the server side. I thought in using javascript but maybe there is a better option. if you're working in a page outside of the /catalog folder, all you need to do is add the /catalog/includes folder to your include list, and include application_top.php - which sets up all of the osc session stuff for you. you need to set up the include path because application_top.php includes a bunch of other stuff...and you don't want to have to change all that code. in your code outside of /catalog, place the following up at the top: set_include_path(get_include_path() . PATH_SEPARATOR . '/public_html/catalog'); include('includes/application_top.php'); the 'public_html/catalog' should be replaced with whatever directory specific stuff you need for your host. then you can use the tep_session_is_registered('customer_id') as normal.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.