Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Idea or Suggestion Login with SSL and Recreate Session (1.3.7)

    Hi,

    On v1.3.7, if a site has a dedicated SSL cert, SSL enabled for login and Recreate Session set to True then login can stop working. To fix (without having to turn off Recreate Session) change line 105 of \includes\modules\pages\login\header_php.php from
    PHP Code:
    zen_redirect(zen_href_link(FILENAME_DEFAULT)); 
    ...to...
    PHP Code:
    zen_redirect(zen_href_link(FILENAME_DEFAULT,'',$request_type)); 
    Sorry this is a bit brief but I've got some kind of viral thing and a long explanation will hurt my head It's all to do with trying to redirect from a SSL page to a non-SSL page and zen_redirect changing it back to a SSL page but zen_href_link thinking you're going from SSL to non-SSL and putting the old zenid in the URL (or something like that).

    TTFN
    Christian.
    P.S. The zen_session_recreate() needs cleaning up.

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

    Default Re: Login with SSL and Recreate Session (1.3.7)

    1. zen_href_link already auto-detects if the $request_type is ssl or not if you don't specify the parameter, largely defaulting to off in most cases.

    What hosting configuration are you working with in order for this to be a challenge?

    2. What 'cleanup' are you speaking of in zen_session_recreate()?
    The v1.4 code has been fully rewritten, but 1.4 is still in development and not ready for release. What specific concerns are you thinking need to be addressed and why?
    .

    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.

  3. #3
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Re: Login with SSL and Recreate Session (1.3.7)

    Hi,

    Please bear with me and I will try to explain in a bit more detail.

    Quote Originally Posted by DrByte View Post
    1. zen_href_link already auto-detects if the $request_type is ssl or not if you don't specify the parameter, largely defaulting to off in most cases.
    If the $connection parameter is not specified in zen_href_link it is defaulted to "NONSSL" in all cases. Later in the code it checks whether you want to go from a SSL page to a NONSSL page and appends the zenid if this is the case.

    zen_redirect will not let you redirect from a SSL page to a NONSSL page. If you try it changes the URL you provide into a HTTPS one.

    So if you have your login page using SSL then the code that says...
    PHP Code:
    zen_redirect(zen_href_link(FILENAME_DEFAULT)) 
    ...does the following...
    1. zen_href_link creates a link to a NONSSL page and attaches the zenid because it thinks you are going from a SSL page to a NONSSL page.
    2. zen_redirect detects that you are trying to go from a SSL page to a NONSSL page and changes the link to be a SSL one.

    If you add into the mix the regeneration of the zenid then what can happen is that zen_href_link adds the old zenid to the URL rather than the new one. Note that this is only an issue with a dedicated SSL cert because zen_recreate_session does nothing if you are using a shared SSL cert.

    Quote Originally Posted by DrByte View Post
    What hosting configuration are you working with in order for this to be a challenge?
    I've personally seen it on Zen Cart v1.3.7, running on PHP 4.4.2 on an Apache server with a dedicated SSL cert. User goes straight to the front page of the site, clicks the login link and logs in. A new zenid is created and a cookie set but the user is redirect back to the main page with the old zenid in the URL. The user then appears to have not been logged in and no error message is given. The issue has been reported on the forums numerous times over the past year and the usual answer is "turn off recreate session, it is a hosting issue". It is not really a hosting issue, recreate session is doing it's job and regenerating the zenid. The problem is with the logic Zen Cart uses for moving between SSL and non-SSL pages.

    Quote Originally Posted by DrByte View Post
    2. What 'cleanup' are you speaking of in zen_session_recreate()?
    The v1.4 code has been fully rewritten, but 1.4 is still in development and not ready for release. What specific concerns are you thinking need to be addressed and why?
    The code currently looks like this...
    PHP Code:
          if ($http_domain == $https_domain) {
          
    $saveSession $_SESSION;
          
    $oldSessID session_id();
          
    session_regenerate_id();
          
    $newSessID session_id();
          
    session_id($oldSessID);
          
    session_id($newSessID);
          if (
    STORE_SESSIONS == 'db') {
            
    session_set_save_handler('_sess_open''_sess_close''_sess_read''_sess_write''_sess_destroy''_sess_gc');
          }
          
    session_start();
          
    $_SESSION $saveSession;
          
    whos_online_session_recreate($oldSessID$newSessID);
        } else { 
    As it stands, most of that code is unnecessary and code be done with...
    PHP Code:
          if ($http_domain == $https_domain) {
          
    $oldSessID session_id();
          
    session_regenerate_id();
          
    $newSessID session_id();
          
    whos_online_session_recreate($oldSessID$newSessID);
        } 
    I suspect that there was originally a session_destroy() in there that was either removed on purpose or accidentally. Without the session_destroy() most of the current code is not needed. The check for $http_domain == $https_domain is interesting too. It basically means that sessions are not recreated if you are using a shared SSL cert. Possibly this is because of cookie issues on different domains but isn't that what all the passing of the zenid between SSL and non-SSL pages is to get around? Maybe someone was testing the login code with a shared SSL cert, found the issue described above and fixed it by just not recreating the session.

    I hope that helps.
    Regards,
    Christian.

 

 

Similar Threads

  1. Replies: 8
    Last Post: 28 Jul 2011, 11:35 PM
  2. Suddenly customers cannot login unless Recreate Session is False
    By Peter Homann in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 1 Jun 2011, 01:13 PM
  3. Recreate Session & Shared SSL.
    By gaffettape in forum Upgrading from 1.3.x to 1.3.9
    Replies: 8
    Last Post: 6 May 2010, 03:13 PM
  4. create account and session recreate
    By delia in forum General Questions
    Replies: 5
    Last Post: 1 Sep 2009, 05:46 PM
  5. 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