Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    4
    Plugin Contributions
    0

    Default How to tell if a user is logged in?

    If the user is logged in, I'd like to show a 'view cart' link instead of a 'sign in/register' link.

    Is there a reference anywhere to global variables, or a convenient snippet I can drop in?

    I'm hoping it's something like:

    if ($user_logged_in) {.... or something similar

    Thanks
    Tabor Carlton // Interactive Art Director

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: How to tell if a user is logged in?

    There's an example of that already in the default tpl_header.php: The login link turns to a logout link if the customer is already logged in. And the "shopping cart" and "checkout" links appear if something is in the cart.
    .

    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
    Aug 2009
    Posts
    4
    Plugin Contributions
    0

    Default Re: How to tell if a user is logged in?

    Thanks Dr. Byte,

    I'd overlooked that as I'd customized that page a lot and ripped a lot of code out.

    here it is for other people's sake (just testing a session):

    PHP Code:
    <?php if ($_SESSION['customer_id']) { 
              
    $content .= 'logged in content here';
      } else { 
              
    $content .= 'logged out content here';
      } 
    ?>
    Tabor Carlton // Interactive Art Director

 

 

Similar Threads

  1. Tell visitors why they've been logged out?
    By kamion in forum General Questions
    Replies: 4
    Last Post: 20 Jan 2012, 07:51 AM
  2. Replies: 4
    Last Post: 22 Jul 2011, 10:27 PM
  3. How do I identify which admin user is logged in?
    By SteveS14 in forum General Questions
    Replies: 2
    Last Post: 19 Feb 2010, 10:23 PM
  4. How do I show quantity discounts when user not logged in?
    By carystevens in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 21 Jul 2009, 04:56 AM
  5. how to tell if logged in?
    By adornit in forum General Questions
    Replies: 14
    Last Post: 4 Jul 2008, 12:14 AM

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