-1

How can I find out the email address of a user when he's logged in to osCommerce? I want to display the following message at the top of my website:

When not logged in:

Welcome Guest! (Login or Signup)

When logged in:

Welcome {email address} (Logout)

What do I need to do for this to happen?

random
  • 9,774
  • 10
  • 66
  • 83
sumit
  • 10,935
  • 24
  • 65
  • 83

1 Answers1

2

When a customer successfully logs into their account, the following session variable is filled in with a non-zero, non-empty integer value:

$_SESSION['customer_id']

If your install hasn't been upgraded away from using globals, it will be in the following:

$customer_id

From there you can use it to query the database to look up their email address and whatever else.

Or you can change your login code to fetch and add the email address into the session so you can reference it later and save yourself an extra database query.

random
  • 9,774
  • 10
  • 66
  • 83