Forums / General Questions / How to detect if logged in?

How to detect if logged in?

Locked

Views: 1,608

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
3 Dec 2007, 3:25 PM
#1
monkeyjr47906 avatar

monkeyjr47906

New Zenner

Join Date:
Nov 2007
Posts:
72
Plugin Contributions:
0

How to detect if logged in?

Hi I'm trying add code to a sidebox (using php) so that it will only show links if a customer is signed in , suggestions? HELP!

I'm not sure where to start with this.

Thanks!

3 Dec 2007, 4:01 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: How to detect if logged in?

If you look at the order_history sidebox, you'll see that its first line is an IF statement checking whether the customer ID is set and valid.

You could employ similar logic.

  if (isset($_SESSION['customer_id']) && (int)$_SESSION['customer_id'] != 0) {
    blahblahblah
  }

.
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 Dec 2007, 4:12 PM
#3
monkeyjr47906 avatar

monkeyjr47906

New Zenner

Join Date:
Nov 2007
Posts:
72
Plugin Contributions:
0

Re: How to detect if logged in?

Thanks Dr. Byte ...

I checked around and it seems after checking some other posts you can use this

When this is defined ...

<?php if($SESSION['customer_id']?>

it means the customer is logged in (here is the link ... http://www.zen-cart.com/forum/showthread.php?t=48929

3 Dec 2007, 4:48 PM
#4
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: How to detect if logged in?

Almost the same code, however I would recommend DrByte's method.
BTW, if you haven't know yet, he is one of the coders of ZenCart, so take his words for it ^^.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me