Forums / General Questions / logoff page isn't redirecting properly

logoff page isn't redirecting properly

Started by congerman on 1 Mar 2016, 6:34 PM · Views: 5,156

Results 21 to 40 of 58
2 Mar 2016, 10:50 PM
#21
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

logoff page isn't redirecting properly

Congerman:

still waiting in anticipation for version 2 that has been on the cards for ages before updating and then updating again

Umm, well, other technology changes (PHP specifically) may force you to do otherwise. Any currently acceptable version of PHP is already ahead of the original design parameters of ZC 1.5.1... PHP 5.4 is considered even below minimum recommended by the PHP community and with that ZC 1.5.1 requires minor mods...5.6 is the minimum suggested and 7.0 is becoming commonplace (ZC 1.5.5 is the first version that will support that).

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

2 Mar 2016, 11:15 PM
#22
congerman avatar

congerman

Zen Follower

Join Date:
Oct 2008
Posts:
392
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

ok dam more work on my, and my customers, 22 zen cart shops lol Good night and thank you for the advice

14 May 2018, 6:16 AM
#23
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

I've just moved my site to a new server, and have expereinced the same error.

The Fix Cache Key module is not supposed to be needed after v1.5.3. I'm running v1.5.5d, so should I still use this, or will this cause problems?

14 May 2018, 8:30 AM
#24
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

I had a dedicated IP with SSL on the old server. Had my whole cpanel account moved over to another server, including the SSL certificate (no dedicated IP on the new server, don't think I need it). Not sure if all that is relevant, but everything appears to be working perfectly on the new server, except the logout page throwing up re-direct errors.
Perhaps there's just a cache I need to clear???

14 May 2018, 12:46 PM
#26
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

Thank you for trying that. yes that is the correctg site.

Yes that URL worked fine for me as well. But it does not work if I actually log in, then click the logout link.

I also tried from a browser (IE), that I had not used before for this site. I created an account, logged in, then logged out. It worked first time (although it seemed to take a long time). Tried it again, then it came up with the same error (too many redirects).

I've since cleared all the data and cookies from the browser, it still comes up with the error.

Old server: SSL + dedicated IP
New server: same SSL certificate but no dedicicated IP

Old server PHP 5.4
New server: PHP 5.6 or 7.1

As I mentioned, the site worked perfectly on the old server. When the complete cpanel account was moved to a new server, this issue started happening.
Should I run the Fix Cache Key module, or will this not work on v1.5.5d?

14 May 2018, 12:58 PM
#27
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

The site is pretty much a standard installation, freshly installed from v1.5.5d with the sheffield blue responsive module. No other modules installed that modifiy URLs or anything like that.
I temporarily renamed my .htaccess to see if that was causing it, but that made no difference.

15 May 2018, 5:48 AM
#28
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

I'm really don't know where to start with this... if anyone can offer any tips, I'd really appreciate it!

15 May 2018, 6:47 PM
#29
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,120
Plugin Contributions:
56

Re: logoff page isn't redirecting properly

Check your /includes/configure.php file, making sure that it's "in sync" with any .htaccess redirect directives.

That is, if your configure.php contains a www. prefix, make sure that the .htaccess isn't redirecting to non-www. (and vice versa).

Make sure, too, that your configure.php specifies either 'true' or 'false' for the USE_SSL definition; I've seen 1.5.5 upgrades where it's set to '' (an empty string), which can be problematic.

15 May 2018, 9:47 PM
#30
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: logoff page isn't redirecting properly

to make sure i understand, this worked perfectly before; the site was moved to a new server; and now you are getting too many redirects before it errors out? is that correct?

if so, it seems that your new server is configured differently than the old server. from what i can gather, the logoff page is NOT destroying the session data. the code from:

includes/modules/pages/logoff/header_php.php

/**
  * Check if there is still a customer_id
  * If so, kill the session, and redirect back to the logoff page
  * This will cause the header logic to see that the customer_id is gone, and thus not display another logoff link
  */
if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
  zen_session_destroy();
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

this would explain why the page works perfectly if one is not logged in, but fails when the customer is logged in. so something is different on the server with regards to the session data.

one could try the following code:

/**
  * Check if there is still a customer_id
  * If so, kill the session, and redirect back to the logoff page
  * This will cause the header logic to see that the customer_id is gone, and thus not display another logoff link
  */
if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
  session_start();
  zen_session_destroy();
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

and see if that addresses the problem.... but i'm really guessing blind based on some reading i'm doing.

there are plenty of threads out there on session_destroy not deleting $_SESSION variables. the above references one such solution.

good luck!

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

15 May 2018, 9:51 PM
#31
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: logoff page isn't redirecting properly

lat9:

Check your /includes/configure.php file, making sure that it's "in sync" with any .htaccess redirect directives.

That is, if your configure.php contains a www. prefix, make sure that the .htaccess isn't redirecting to non-www. (and vice versa).

Make sure, too, that your configure.php specifies either 'true' or 'false' for the USE_SSL definition; I've seen 1.5.5 upgrades where it's set to '' (an empty string), which can be problematic.

i do not think these 'solutions' are the problem. see screenshot:

Attachment 17840

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

16 May 2018, 9:24 AM
#32
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

Thank you!

carlwhat:

to make sure i understand, this worked perfectly before; the site was moved to a new server; and now you are getting too many redirects before it errors out? is that correct?
Yes that is exactly what happened.

carlwhat:

if so, it seems that your new server is configured differently than the old server. from what i can gather, the logoff page is NOT destroying the session data. the code from:

includes/modules/pages/logoff/header_php.php

/**

  • Check if there is still a customer_id
  • If so, kill the session, and redirect back to the logoff page
  • This will cause the header logic to see that the customer_id is gone, and thus not display another logoff link
    */
    if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
    zen_session_destroy();
    zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
    }
> 
> this would explain why the page works perfectly if one is not logged in, but fails when the customer is logged in.  so something is different on the server with regards to the session data.
> 
> one could try the following code:
> 
> ```
/**
  * Check if there is still a customer_id
  * If so, kill the session, and redirect back to the logoff page
  * This will cause the header logic to see that the customer_id is gone, and thus not display another logoff link
  */
if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
  session_start();
  zen_session_destroy();
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

and see if that addresses the problem.... but i'm really guessing blind based on some reading i'm doing.

there are plenty of threads out there on session_destroy not deleting $_SESSION variables. the above references one such solution.

good luck!
I tried that, but it did not work.

I'll look for other threads relating to this, see if I can find a solution.

THank you!

16 May 2018, 9:34 AM
#33
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

Hmmm could not find any other references, except really old one.

Should it perhaps be zen_session_start(); instead of session_start();?

16 May 2018, 11:24 AM
#34
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

There are my session settings:
Session Directory /home2/xxxxxx/public_html/cache
Cookie Domain True
Force Cookie Use False
Check SSL Session ID False
Check User Agent False
Check IP Address False
Prevent Spider Sessions True
Recreate Session True
IP to Host Conversion Status true
Use root path for cookie path False
Add period prefix to cookie domain True

16 May 2018, 12:53 PM
#35
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: logoff page isn't redirecting properly

ok, this is one of the things that drives me crazy - not understanding how something works! perhaps @DrByte (or someone else) can chime in.

i have a working ZC with a working logoff page. if i change my code to such:

if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
    echo '111--------> ' .$_SESSION['customer_id'] . ' <----------';
  zen_session_destroy();
    echo '2222--------> ' . $_SESSION['customer_id'] . ' <----------';
    die(__FILE__ . ':' . __LINE__);
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

my customer_id is still there, and yet my logoff page works, so my customer_id is getting destroyed somewhere else. in fact, when i looked at all my $_SESSION variables here, i did not see zen_session_destroy() doing much of anything (although i did not look that close). what to make of that?

my page works, yours does not. you can try the following code:

if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
  zen_session_destroy();
  unset($_SESSION['customer_id']);
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

pretty sure that will work, although i'm not sure about any other intended consequences....

let us know.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

17 May 2018, 7:34 AM
#36
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

Thank you again!

It does not seem to work either... unless the logoff file is cashed somehow. I tried several times with different browsers.

17 May 2018, 10:16 AM
#37
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: logoff page isn't redirecting properly

try running that fix cache key file as indicated here:

https://www.zen-cart.com/showthread.php?219632-logoff-page-isn-t-redirecting-properly&p=1304910#post1304910

despite it saying it is not necessary after v1.5.3, it can not hurt.

if that does not work, change the code as such, and report back what happens:

if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
  zen_session_destroy();
  die('trying to logoff');
  unset($_SESSION['customer_id']);
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

18 May 2018, 8:01 AM
#38
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

I tried the fix cache key, did not fix it.

Tried your new code, it comes up with a blank page with just your text "trying to logoff" at the top left.

18 May 2018, 10:50 AM
#39
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: logoff page isn't redirecting properly

lat9:

Check your /includes/configure.php file, making sure that it's "in sync" with any .htaccess redirect directives.

That is, if your configure.php contains a www. prefix, make sure that the .htaccess isn't redirecting to non-www. (and vice versa).

Make sure, too, that your configure.php specifies either 'true' or 'false' for the USE_SSL definition; I've seen 1.5.5 upgrades where it's set to '' (an empty string), which can be problematic.

Yes, all checked and correct.

18 May 2018, 2:51 PM
#40
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: logoff page isn't redirecting properly

ttfan:

I tried the fix cache key, did not fix it.

Tried your new code, it comes up with a blank page with just your text "trying to logoff" at the top left.

we are in the right place.... last try:

if (!empty($_SESSION['customer_id']) || !empty($_SESSION['customer_guest_id'])) {
  zen_session_destroy();
  unset($_SESSION['customer_id']);
  unset($_SESSION['customer_guest_id']);
  zen_redirect(zen_href_link(FILENAME_LOGOFF, $logoff_lang));
}

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.