If this is your first visit, check our documentation. To post, register or login.

How to tell if a user is logged in?

Locked

Started by tabor_carlton on 24 Aug 2009, 4:10 PM · Views: 1,007

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
24 Aug 2009, 4:10 PM
#1
tabor_carlton avatar

tabor_carlton

New Zenner

Join Date:
Aug 2009
Posts:
4
Plugin Contributions:
0

Post #1 by tabor_carlton

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

24 Aug 2009, 5:25 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

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.

25 Aug 2009, 3:32 AM
#3
tabor_carlton avatar

tabor_carlton

New Zenner

Join Date:
Aug 2009
Posts:
4
Plugin Contributions:
0

Post #3 by tabor_carlton

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 if ($_SESSION['customer_id']) { 
  		$content .= 'logged in content here';
  } else { 
      	$content .= 'logged out content here';
  } ?>

Tabor Carlton // Interactive Art Director