osCmax v2.5 User Manual
Results 1 to 4 of 4

How Can I Retain Session Id Outside Of osCommerce Catalog Directory?

This is a discussion on How Can I Retain Session Id Outside Of osCommerce Catalog Directory? within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; Hi, Using osCommerce, I am aware that tep_href_link makes sure the Session ID gets attached to the URL being called. ...

      
  1. #1
    Lurker
    Join Date
    May 2007
    Posts
    2
    Rep Power
    0


    Default How Can I Retain Session Id Outside Of osCommerce Catalog Directory?

    Hi,
    Using osCommerce, I am aware that tep_href_link makes sure the Session ID gets attached to the URL being called. However, it uses HTTP_SERVER . DIR_WS_HTTP_CATALOG (for NONSSL, anyway), meaning "catalog" must be part of the URL path.

    I want my customer to be able to back out to higher level pages, above the "catalog" directory -- and then return to their shopping when they are ready.

    I tried writing my own version of tep_href_link. I called it agp_tep_href_link and changed its signature to accept a boolean that tells whether it is at the "top" level, above "catalog". If, in "catalog/includes/header.php", I use this new function to go to a top-level page, it works fine: the page appears as expected, and the URL still contains the Session ID. HOWEVER, if I use this new function in my top-level page, I cannot figure out how to call the new method.

    Here is the modified agp_tep_href_link...
    // The HTML href link wrapper function written by AG Productions.// This version of the method allows the user to navigate to the top-level pages (above ../catalog) and still retain the session id.
    Code:
    function agp_tep_href_link($topLevel = false, $page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) { global $request_type, $session_started, $SID; if (!tep_not_null($page)) { die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>'); } if ($connection == 'NONSSL') { if ($topLevel) { $link = HTTP_SERVER . '/'; } else { $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG; } } elseif ($connection == 'SSL') { if (ENABLE_SSL == true) { if ($topLevel) { $link = HTTPS_SERVER . '/'; } else { $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG; } } else { if ($topLevel) { $link = HTTP_SERVER . '/'; } else { $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG; } } } else { die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>'); } ... rest of function exactly as in tep_href_link...
    Here is use of it inside catalog/includes/header.php that works fine. Clicking the Home image button takes me to my top-level page, and the Session ID remains in the URL...
    Code:
    <tr><td><a href="<?=agp_tep_href_link(true, 'index.php')?>" title="Home"><?=Tep_Image_Button('Home.gif')?></a><a href="<?=agp_tep_href_link(false, 'account.php')?>" title="My Account"><?=Tep_Image_Button('MyAccount.gif')?></a></td></tr>
    Here is just one of the many failed variations of php code I tried in my top-level menu. This only works if I'm on the Home page, and my other menu options do not appear at all..
    Code:
    <!-- Home -->
    <?php if ($thisPage == "Home") {
    echo '<li class="menuItemSelected"><a title="Home">Home</a></li>';
    } else {
    echo '<li><a href="' . agp_tep_href_link(true, 'index.php') . '" title="Home">Home</a></li>';
    } ?>
    I will greatly appreciate any help. I'm sure the concept is sound. I think my problem lies with my inexperience in php. Ideally, someone already has an elegant solution for this: carrying the Session ID outside of the catalog.
    Cheers,
    Guy

  2. #2
    jpf
    jpf is offline
    osCMax Testing Team
    jpf's Avatar
    Join Date
    Sep 2003
    Location
    Manitoba, Canada
    Posts
    2,699
    Rep Power
    22


    Default Re: How Can I Retain Session Id Outside Of osCommerce Catalog Directory?

    Maybe with cookie bases session would be a better idea - no SID in URL.

  3. #3
    Lurker
    Join Date
    May 2007
    Posts
    2
    Rep Power
    0


    Default Re: How Can I Retain Session Id Outside Of osCommerce Catalog Directory?

    Thx for that, jpf. How would I switch the engine to use cookies instead of a SID in the URL?
    Guy

  4. #4
    jpf
    jpf is offline
    osCMax Testing Team
    jpf's Avatar
    Join Date
    Sep 2003
    Location
    Manitoba, Canada
    Posts
    2,699
    Rep Power
    22


    Default Re: How Can I Retain Session Id Outside Of osCommerce Catalog Directory?

    Force cookies....

    Under Configuration, Session....

Similar Threads

  1. Rot or in Catalog directory
    By theengineer in forum osCmax v2 Installation issues
    Replies: 1
    Last Post: 02-28-2007, 10:10 PM
  2. Warning: Session directory doesnt exist
    By benlogan in forum osCmax v2 Installation issues
    Replies: 1
    Last Post: 08-06-2005, 04:54 AM
  3. How do you retain Session/Product ID in Standard HTML site
    By Ttownsend in forum osCommerce 2.2 Modification Help
    Replies: 7
    Last Post: 07-19-2005, 01:48 AM
  4. Error: Catalog images directory does not exist: catalog/imag
    By Korsh in forum osCommerce 2.2 Installation Help
    Replies: 1
    Last Post: 11-26-2003, 07:31 PM
  5. warning directory does not exist: /tmp.Session will not work
    By mickthefish in forum osCommerce 2.2 Installation Help
    Replies: 2
    Last Post: 09-18-2003, 04:09 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
  •