Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Username In Header?


Craft_Shop_Girl

Recommended Posts

Posted
Hi!

How can I display the username in header once he/she login?

 

You could pass the user name in the cookie, or use another cookie to store the user name until they log out.

Posted
You could pass the user name in the cookie, or use another cookie to store the user name until they log out.

 

Thanks for the response. I am new with this and have no idea how to do what you mentioned. Can you be more specific on how to do it?

 

Thanks!

Posted

Thanks for the response. I am new with this and have no idea how to do what you mentioned. Can you be more specific on how to do it?

 

Thanks!

 

Find the below code in your login.php file. It should be near the top of the file.

 

if (!tep_validate_password($password, $check_customer['customers_password'])) {
       $error = true;
     } else {
       if (SESSION_RECREATE == 'True') {
         tep_session_recreate();
       }

 

You'll want to add the following line after that to the file. It'll look something like this.

 

if (!tep_validate_password($password, $check_customer['customers_password'])) {
       $error = true;
     } else {
       if (SESSION_RECREATE == 'True') {
         tep_session_recreate();
       }

[color="#FF0000"]setcookie('UserName', $check_customer['customers_firstname'], time()+3600, '/', domain_name_here);[/color]

 

Replace domain_name_here with your actual domain name. ie. www.oscommerce.com would be the domain name for the main osCommerce site.

Also, if the customer's first name is not what you want, you'll have to change that to whatever field you want. If the username is the e-mail, then

replace $check_customer['customers_email_address'].

 

The next step is to go into the files you want the user name to display on, and add the following code where you want it to be displayed.

 

       <?php if(isset($_COOKIE['UserName'])) { echo $_COOKIE['UserName']; } ?>

 

Hope that helped! ;)

Posted

wouldnt

<?php echo tep_customer_greeting(); ?>

be almost what your looking for? Just need to alter the defines or create a new define in your english file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...