Zen Cart Logo
Forums / Bug Reports / Login page redirects to cookie_usage after cache has been cleared

Login page redirects to cookie_usage after cache has been cleared

Locked

Views: 3,511

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
11 Oct 2010, 8:37 PM
#1
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Login page redirects to cookie_usage after cache has been cleared

I've got Force Cookie Use=true in the session settings.

I ran the following procedure on firefox

  • Clear browser cache (deletes exisiting cookie)
  • Go to logon page (eg from a bookmake)
  • Redirects to /index.php?main_page=cookie_usage
  • Go to logon page again
  • Everything works ok

I had a look at the code (includes/modules/pages/login/header_php.php) and on line 16 I see

if ($session_started == false) {
zen_redirect(zen_href_link(FILENAME_COOKIE_USAGE));
}

so the question is, why would $session_statrted by false here ?

Danel.

11 Oct 2010, 11:15 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Login page redirects to cookie_usage after cache has been cleared

Is either your Catalog or your Admin working?

Could you post, from the server, without the username, password and your secret admin directory, the files:
/includes/configure.php
/admin/includes/configure.php

11 Oct 2010, 11:42 PM
#3
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

Yes, everything is working. The only problem is logon after clearing the cache. If you go to the logon page twice, the logon page works again.

It looks like $session_started==true on the 2nd page request after clearing the cache.

Daniel.

11 Oct 2010, 11:57 PM
#4
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

I don't think it's relevent but here is configure.php file

<?php
/**
 * @package Configuration Settings circa 1.3.8
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 */


/*************** NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php. ***********/
/***************       The 2 files should be kept separate and not used to overwrite each other.      ***********/

//Protostack
define('IMG1_URL', 'http://img1.protostack.com');
define('IMG2_URL', 'http://img2.protostack.com');

// Define the webserver and path parameters
  // HTTP_SERVER is your Main webserver: eg-http://www.your_domain.com
  // HTTPS_SERVER is your Secure webserver: eg-https://www.your_domain.com
  define('HTTP_SERVER', 'http://www.protostack.com');
  define('HTTPS_SERVER', 'https://www.protostack.com');

  // Use secure webserver for checkout procedure?
  define('ENABLE_SSL', 'false');

// NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes!
// * DIR_WS_* = Webserver directories (virtual/URL)
  // these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder)
  define('DIR_WS_CATALOG', '/');
  define('DIR_WS_HTTPS_CATALOG', '/');

  define('DIR_WS_IMAGES', 'images/');
  define('DIR_WS_INCLUDES', 'includes/');
  define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
  define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
  define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
  define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
  define('DIR_WS_DOWNLOAD_PUBLIC', DIR_WS_CATALOG . 'pub/');
  define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/');

  define('DIR_WS_PHPBB', '/var/www/www.protostack.com/forum/');

// * DIR_FS_* = Filesystem directories (local/physical)
  //the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/
  define('DIR_FS_CATALOG', '/var/www/www.protostack.com/');

  define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
  define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');
  define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/');
  define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
  define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');

// define our database connection
  define('DB_TYPE', 'mysql');
  define('DB_PREFIX', '');
  define('DB_SERVER', 'localhost');
  define('DB_SERVER_USERNAME', 'XXXXXXXXXXXX');
  define('DB_SERVER_PASSWORD', 'XXXXXXXXXXXX');
  define('DB_DATABASE', 'XXXXXXXXXXXX');
  define('USE_PCONNECT', 'false');
  define('STORE_SESSIONS', 'db');
  // for STORE_SESSIONS, use 'db' for best support, or '' for file-based storage

  // The next 2 "defines" are for SQL cache support.
  // For SQL_CACHE_METHOD, you can select from:  none, database, or file
  // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache 
  // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder
  // ie: /path/to/your/webspace/public_html/zen/cache   -- leave no trailing slash  
  define('SQL_CACHE_METHOD', 'none'); 
  define('DIR_FS_SQL_CACHE', '/var/www/www.protostack.com/cache');

// EOF
12 Oct 2010, 12:19 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Login page redirects to cookie_usage after cache has been cleared

I created an account on your site and I have no problem logging in in FireFox nor in IE ...

I am not quite sure what problem you are having as I cannot reproduce it on your site ... :unsure:

12 Oct 2010, 12:28 AM
#6
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

OK, try this.

  1. Clear your cache, including the cookies
  2. Go to http://www.protostack.com/index.php?main_page=login (Just paste that address in your browser)
  3. You should then get http://www.protostack.com/index.php?main_page=cookie_usage
  4. Go to http://www.protostack.com/index.php?main_page=login again
  5. Logon/register page is now displayed
12 Oct 2010, 12:42 AM
#7
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

One thing to note is that I do have the "Cookie Domain" setting set to true under Sessions. This means that the cookie should for https://www.protostack.com, not protostack.com.

When I browse to http://www.protostack.com/index.php?main_page=index after just purging my cache, firefox reports the cookies belonging to protostack.com.

Could this be a factor?

12 Oct 2010, 12:47 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Login page redirects to cookie_usage after cache has been cleared

Click Reply and answer the list of questions that is displayed ...

Is there a reason I would be pasting the link to the login into my browser vs using the site in a normal manner?

What happens if you turn off whatever redirect you have on your site?

If I go to:
protostack.com

it is taking me to:
protostack.com/blog/

it strikes me that your redirect is causing issues on this ...

12 Oct 2010, 1:03 AM
#9
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

The reason for pasting the url into the browser, is that I did a bunch of testing and I distilled the problem down to it's essence. I thought this was the best way to describe it.

Let me describe the real problem as I experience it.

http://www.protostack.com/blog is a wordpress page. This page does not setup any zen sessions. When you click on the Login link (top right in header) it takes you to thee logon page.

So if we perform the following steps we can reproduce the problem in a more "Real world" example.

  1. Clear the cache including cookies
  2. Go to http://www.protostack.com/blog
  3. Click on login (top right in header)
  4. http://www.protostack.com/index.php?main_page=cookie_usage is displayed
  5. Click on login again
  6. http://www.protostack.com/index.php?main_page=login is now displayed

it seems that the login page needs at least 1 zencart page to be displayed before it can work.

I've disabled the redirection and I'm getting the same behaviour.

12 Oct 2010, 2:14 AM
#10
drbyte avatar

drbyte

Sensei

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

Re: Login page redirects to cookie_usage after cache has been cleared

Ajeh:

Click Reply and answer the list of questions that is displayed ...
Need that information still ...

12 Oct 2010, 2:47 AM
#11
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

Oh sorry. I understand what you mean now. I thought you were refering to the questions in your post.

Version 1.3.9f

I was running 1.3.8.something about 6 weeks ago. I upgraded to 1.3.9d, then 1.3.9e then 1.3.9f.

What addons ?

  • Google Base Feeder v 1.7.4
  • Tabbed Products Pro 1.06c
  • Dymo label printing 1.1 (Customised)
  • Add customers from admin 1.07
  • Sitemap XML 2.1.0
  • Recover Cart Sales 3.1.0
  • Ask a Question 1.9
  • customer_nickname_1-0
  • Login as Customer

Customisations include:

  • Template
  • Custom service that creates orders based on ebay sales
  • Customised invoice layout in admin
  • Customised stuff in admit to deal with the ebay sales (icons in lists etc)
  • No session based customisations

I also run a wordpress site on the same host. This site uses several plugins that help integrate to zen cart, including a module that integrates the logons.

Yes I have looked at the FAQ area and I have searched the forum.

I don't know when the problem started, but I do know when I noticed it (last night).

This is my first store and I've been running it for 2 years.

12 Oct 2010, 2:58 AM
#12
drbyte avatar

drbyte

Sensei

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

Re: Login page redirects to cookie_usage after cache has been cleared

Protostack:

I also run a wordpress site on the same host. This site uses several plugins that help integrate to zen cart, including a module that integrates the logons.
Can you elaborate on what that code does?

12 Oct 2010, 8:05 AM
#13
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

All account management and logon is done on zencart. On the wordpress pages I have links going to the zencart logon and registration pages.

When the user logs onto zencart, extra session variable are create for the wordpress user.

The problem I'm experiencing occurs before this code is hit. I'm currently building a test environment with a fresh and unadulterated copy of 1.3.9g. I'll try and reproduce the issue there.

In the meantime I think I have found the cause of the problem. In init_sessions.php on line 58 your should see...

if (SESSION_FORCE_COOKIE_USE == 'True') {
  zen_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, '/', (zen_not_null($current_domain) ? $current_domain : ''));

  if (isset($_COOKIE['cookie_test'])) {
    zen_session_start();
    $session_started = true;
  }

I believe the isset($_COOKIE['cookie_test']) test should always fail in the scenario where you start with no cookies (eg first visit). You need to reload the page to get the cookie values.

12 Oct 2010, 10:02 AM
#14
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

OK, I've reproduced this problem on a newly installed version (1.3.9g) of zencart.

to reproduce the problem

  1. clear cache and cookies
  2. go to http://www.studyelements.com/index.php?main_page=login (just type the address in the browser or open a bookmark)
  3. get http://www.studyelements.com/index.php?main_page=cookie_usage
  4. go to http://www.studyelements.com/index.php?main_page=login again
  5. this time you get the logon/registration page

Interestingly firefox reports the cookies as belonging to studyelements.com, even though Cookie Domain=true

I ran the same test on IE. The same behaviour with the cookie_usage page occurs but when I look at the cookies, it looks like the correct domain.

12 Oct 2010, 9:09 PM
#15
drbyte avatar

drbyte

Sensei

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

Re: Login page redirects to cookie_usage after cache has been cleared

Have you changed your session settings to Force Cookie Use for some reason?

12 Oct 2010, 10:54 PM
#16
protostack avatar

protostack

New Zenner

Join Date:
Jul 2008
Posts:
29
Plugin Contributions:
0

Re: Login page redirects to cookie_usage after cache has been cleared

My site has some pages that are served by wordpress and some that are served by zencart.

If I didn't force cookie usage, then in some circumstances the session id would be in the querystring. If the user jumps between zencart and wordpress pages then sessions would be lost.

there are workarounds for this problem, but enforcing cookies seemed to be the easiest.