Results 1 to 6 of 6
  1. #1

    Default Redirect after login/registration

    Hi guys, I have a slight problem with the redirect from the login page/registration, I'll explain: in my site use a lot of extra pages to present the products.

    in these extra pages there is a button that leads to files that are in a folder in the root directory but that is not a zen cart folder.

    I would that the user has logged in before accessing these files, so if the user click on the button to access these files without being logged in is redirected to the login page.

    The ideal for me would be to redirect the user to these files after login (if coming from these extra pages), but I've seen is a bit 'problematic doing a redirect to non zen cart files and I would be fine also redirect the extra page of origin.

    I made it in this way:

    The extra page of origin sends the customer ID through get to the landing page (the non zen cart file) and in the landing page I entered:

    Code:
    if($_GET['customers_id']==''){
    header('Location: http://www.mysite.com/index.php?main_page=login&page=page');
    }
    and it works, it will redirect to the login page if the user is not logged sending with get the variable "page"

    then I inserted in the file includes/modules/page/login/header_php.php this code

    Code:
    if ($_GET['page']!='') {
      if ($origin_href != zen_href_link(FILENAME_DEFAULT)) {
        zen_redirect($origin_href);
      }
    }

    but it doesn't work, someone could help me?

    Thanks to anyone who wants to answer

    the version of zen cart is 1.3.9h
    http://www.allprints.it
    Stampa le tue foto online

  2. #2

    Default Re: Redirect after login/registration

    Thanks, I solved it, just added
    Code:
    $_SESSION['navigation']->set_snapshot();
    to includes/modules/pages/extrapage_I_want_to redirect_to/header_php.php.
    as seen here http://www.zen-cart.com/forum/showthread.php?t=37330
    forget the code above, there is no need to add anything else

    thanks to DrByte
    http://www.allprints.it
    Stampa le tue foto online

  3. #3
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Redirect after login/registration

    I realize I'm digging up an old thread, but it is obviously still relevant as I ran into the same issue with a fresh install. Previously I had my own contrib called SessionWatcher which did a couple of things, one of which was ensuring a user went back to the page they came from after logging in (something that just seems obvious to me from a UX point of view). I only recently upgraded to 1.5.4 and see that SessionWatcher doesn't work (no surprise). I set about updating it but then I realized this is a much easier way of achieving the same thing.

    So... does anyone see any reason why we can't add something like this:

    Code:
      if (!$_SESSION['customer_id']) {
        if (($_GET['main_page'] != FILENAME_LOGIN) && ($_GET['main_page'] != FILENAME_LOGOFF) && ($_GET['main_page'] != FILENAME_TIME_OUT) && ($_GET['main_page'] != FILENAME_CREATE_ACCOUNT_SUCCESS) && ($_GET['main_page'] != FILENAME_CREATE_ACCOUNT)) { 
          $_SESSION['navigation']->set_snapshot();
        }
      }
    near the top of /includes/templates/MY_TEMPLATE/common/html_header.php?

    It could be the very first line of PHP in that file, say directly above where you find:
    Code:
    require(DIR_WS_MODULES . zen_get_module_directory('meta_tags.php'));
    I don't immediately see a problem and it certainly seems to work in my initial testing. But I'm open to suggestions. It probably shouldn't be done in a template file, but that seemed the easiest thing to do without monkeying around with files that are going to be destroyed in an update.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,478
    Plugin Contributions
    88

    Default Re: Redirect after login/registration

    At a minimum, you'll want to add FILENAME_PAGE_NOT_FOUND to your list.

  5. #5
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Redirect after login/registration

    good call.

  6. #6
    Join Date
    Jun 2005
    Location
    Kelowna, BC Canada
    Posts
    1,075
    Plugin Contributions
    6

    Default Re: Redirect after login/registration

    another one:

    FILENAME_PASSWORD_FORGOTTEN

    Just confusing when you get redirected there after logging in with a new password :)

 

 

Similar Threads

  1. v151 Redirect Issue after Login
    By yaseent in forum Bug Reports
    Replies: 5
    Last Post: 22 Aug 2014, 04:57 PM
  2. Login Link - Can I redirect to My Account after login?
    By perkiekat in forum General Questions
    Replies: 2
    Last Post: 3 Feb 2010, 01:34 AM
  3. redirect after login
    By teva in forum General Questions
    Replies: 8
    Last Post: 7 Feb 2008, 09:18 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