Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / How to tell if a user is logged in?

How to tell if a user is logged in?

Locked

Views: 1,003

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

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

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

drbyte

Sensei

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

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.

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

tabor_carlton

New Zenner

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

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