User Name Stays on NavBar after Logging Out

Open to all! Ask other shopowners for help.
Moxamint
Member
Posts: 93
Joined: Fri Nov 06, 2020 10:36 am
Phoenix Version:
Has thanked: 33 times
Been thanked: 3 times

User Name Stays on NavBar after Logging Out

Post by Moxamint »

Hi All,

As stated in the Subject, the user name will still show on the Navbar after logging off until I start doing something else. Does anyone have the same issue?

I am running 1.0.8.20.
Last edited by Moxamint on Fri Dec 30, 2022 12:02 pm, edited 2 times in total.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: User Name Stays on NavBar after Logging Out

Post by tessthepup »

Moxamint wrote: Fri Dec 30, 2022 11:55 am Hi All,

As stated in the Subject, the user name will still show on the Navbar after logging off until I start doing something else. Does anyone have the same issue?

I am running 1.0.8.20.
If you mean when directed to the logoff.php page then yes
Moxamint
Member
Posts: 93
Joined: Fri Nov 06, 2020 10:36 am
Phoenix Version:
Has thanked: 33 times
Been thanked: 3 times

Re: User Name Stays on NavBar after Logging Out

Post by Moxamint »

tessthepup wrote: Fri Dec 30, 2022 11:58 am
Moxamint wrote: Fri Dec 30, 2022 11:55 am Hi All,

As stated in the Subject, the user name will still show on the Navbar after logging off until I start doing something else. Does anyone have the same issue?

I am running 1.0.8.20.
If you mean when directed to the logoff.php page then yes
Thanks for the confirmation. Isn't it a little odd for it to behave like that?
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: User Name Stays on NavBar after Logging Out

Post by tessthepup »

Moxamint wrote: Fri Dec 30, 2022 12:01 pm
tessthepup wrote: Fri Dec 30, 2022 11:58 am
Moxamint wrote: Fri Dec 30, 2022 11:55 am Hi All,

As stated in the Subject, the user name will still show on the Navbar after logging off until I start doing something else. Does anyone have the same issue?

I am running 1.0.8.20.
If you mean when directed to the logoff.php page then yes
Thanks for the confirmation. Isn't it a little odd for it to behave like that?
to be honest I have never thought about it as a problem, maybe one of the team could comment.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: User Name Stays on NavBar after Logging Out

Post by Kofod95 »

That behavior appeared sometime between 1.0.4.0 and 1.0.7.12. I would think the name shouldn't show, as that seems counter-intuitive when the message says you are logged out, but I wouldn't regard it as something of high priority to fix.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: User Name Stays on NavBar after Logging Out

Post by burt »

This is normal as the logoff page destroys the session and then the next page click reloads the navbar. Some time back I coded up a quick and easy solution (I don't recall who for, but as it's my code I know I can share it as I like). If you can test this (as it was probably made for a single language shop, and I am not sure which Phoenix version [but that should not be an issue]) let me know if it works, it can be added as the first PRO addon of 2023.

File (assuming using override template, if using a different template change the file location appropriately):
templates/override/includes/hooks/shop/logoff/navbar.php

In that new file:

Code: Select all

<?php
/*
  $Id$

  CE Phoenix, E-Commerce made Easy
  https://phoenixcart.org

  Copyright (c) 2023 Phoenix Cart

  Released under the GNU General Public License
*/

class hook_shop_logoff_navbar {

  function listen_injectSiteEnd() {
    $text = MODULE_NAVBAR_ACCOUNT_LOGGED_OUT;
    
    $logoff_text = <<<LT
<script>
$('#navDropdownAccount').html('$text');
</script>
LT;

    return $logoff_text;
  }

}

The idea is to replace the "Customer Name" with the original dropdown title, when logoff.php is accessed.
I am not here to build for you.
I am here to build with you. Let's help each other.
Moxamint
Member
Posts: 93
Joined: Fri Nov 06, 2020 10:36 am
Phoenix Version:
Has thanked: 33 times
Been thanked: 3 times

Re: User Name Stays on NavBar after Logging Out

Post by Moxamint »

burt wrote: Fri Dec 30, 2022 2:03 pm This is normal as the logoff page destroys the session and then the next page click reloads the navbar. Some time back I coded up a quick and easy solution (I don't recall who for, but as it's my code I know I can share it as I like). If you can test this (as it was probably made for a single language shop, and I am not sure which Phoenix version [but that should not be an issue]) let me know if it works, it can be added as the first PRO addon of 2023.

File (assuming using override template, if using a different template change the file location appropriately):
templates/override/includes/hooks/shop/logoff.php

In that new file:

Code: Select all

<?php
/*
  $Id$

  CE Phoenix, E-Commerce made Easy
  https://phoenixcart.org

  Copyright (c) 2023 Phoenix Cart

  Released under the GNU General Public License
*/

class hook_shop_logoff_navbar {

  function listen_injectSiteEnd() {
    $text = MODULE_NAVBAR_ACCOUNT_LOGGED_OUT;
    
    $logoff_text = <<<LT
<script>
$('#navDropdownAccount').html('$text');
</script>
LT;

    return $logoff_text;
  }

}

The idea is to replace the "Customer Name" with the original dropdown title, when logoff.php is accessed.
Adding the code above in templates/override/includes/hooks/shop/logoff.php did not fix the issue.

Happy Year of the Rabbit! (Glad to see you here again @burt )
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: User Name Stays on NavBar after Logging Out

Post by Kofod95 »

Maybe:
templates/override/includes/hooks/shop/logoff/navbar.php

Good to see you again, Burt, and thank you very much for sharing an actual solution!


BTW, @Moxamint, I was under the impression that the Year of the Rabbit would begin at January 23rd (that is when all the cigars celebrating it will be released) - but I wish the same to you!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: User Name Stays on NavBar after Logging Out

Post by raiwa »

Possible core change in the navbar module:
includes\modules\navbar\nb_account.php line 20:

Code: Select all

      if ( ($GLOBALS['customer'] ?? null) instanceof customer && isset($_SESSION['customer_id']) ) {
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
Moxamint
Member
Posts: 93
Joined: Fri Nov 06, 2020 10:36 am
Phoenix Version:
Has thanked: 33 times
Been thanked: 3 times

Re: User Name Stays on NavBar after Logging Out

Post by Moxamint »

Kofod95 wrote: Sat Dec 31, 2022 6:58 am BTW, @Moxamint, I was under the impression that the Year of the Rabbit would begin at January 23rd (that is when all the cigars celebrating it will be released) - but I wish the same to you!

//Daniel
Thanks @Kofod95 for the fix, but how come you know exactly when the lunar new year will be? Can't wait to have a quiet, peaceful holiday when all my neighbors go out to stuck in a traffic jam!
Kofod95 wrote: Sat Dec 31, 2022 6:58 am Maybe:
templates/override/includes/hooks/shop/logoff/navbar.php

//Daniel
This works!

Cheers, Eddy
Last edited by Moxamint on Sat Dec 31, 2022 12:30 pm, edited 1 time in total.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply