online users counter going mad. (or cookie handling)

Please report bugs here!

Moderator: Thorsten

insecure
Posts: 8
Joined: Sun Sep 06, 2009 12:52 pm

online users counter going mad. (or cookie handling)

Post by insecure » Fri Jan 29, 2010 2:34 pm

After upgrading from 2.5.2 to 2.6.1, the counter for online users seems to go mad. When navigating through my faq-site, the counter for guest users is increased by 1 on every new page load. The problem appeared only when not logged in. After logging in, the counter works as normal.
Clearing PMF related cookies didn't fix this problem.

Searching the forum pointed me to a similar problem some years ago: viewtopic.php?f=2&t=2232&start=0
The problem was related to mod_rewrite. Turning off mod_rewrite fixed the issue.

Disabling mod_rewrite in the pmf config also works for me in 2.6.1. Anyway, I want nice URLs. ;) So I had a look at the pmf source. The problem, as I have pointed out so far, seems to be within inc/Session.php. In 2.5.2 there was

Code: Select all

        setcookie(PMF_COOKIE_NAME_SESSIONID, $sessionId, $_SERVER['REQUEST_TIME'] + PMF_SESSION_EXPIRED_TIME);
in 2.6.1 it is:

Code: Select all

        setcookie(
            PMF_COOKIE_NAME_SESSIONID,
            $sessionId, 
            $_SERVER['REQUEST_TIME'] + PMF_SESSION_EXPIRED_TIME,
            dirname(dirname(__FILE__)),
            $_SERVER['HTTP_HOST'],
            false,
            true);
    }
If I replace dirname(dirname(__FILE__)) with "/" and clear PMF related cookies, the counter works fine again. This is probably not a nice solution, but at least a point to start if anyone else complains. ;-)

While having a look at the PMF related cookies in my browser, I also noticed, that the cookies pmf_sid and pmf_auth are quite different. Maybe the code for setting the pmf_auth cookie should also get some review.

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Fri Jan 29, 2010 2:47 pm

Hi,

I can confirm this issue.
insecure wrote:If I replace dirname(dirname(__FILE__)) with "/" and clear PMF related cookies, the counter works fine again. This is probably not a nice solution, but at least a point to start if anyone else complains. ;-)
this does not fix this issue for me.

I'll work on a fix.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

oldperl
Posts: 37
Joined: Sat Oct 28, 2006 3:03 pm
Location: Franken
Contact:

Re: online users counter going mad. (or cookie handling)

Post by oldperl » Sat Feb 06, 2010 3:36 pm

Hi,

while confirming this issue too i also fixed it for me. In 2.6.2 the function for generating the Cookie in Session.php looks like

Code: Select all

/**
     * Store the Session ID into a persistent cookie expiring PMF_SESSION_EXPIRED_TIME seconds after the page request.
     *
     * @param integer $sessionId Session ID
     * 
     * @return void
     */
    public static function setCookie($sessionId)
    {
        setcookie(
            PMF_COOKIE_NAME_SESSIONID,
            $sessionId, 
            $_SERVER['REQUEST_TIME'] + PMF_SESSION_EXPIRED_TIME,
            dirname(dirname(__FILE__)),
            $_SERVER['HTTP_HOST'],
            false);
    }
The reason for that malfunction is the last parameter, which will not work with every useragent (see Parameters :arrow: http://php.net/manual/en/function.setcookie.php).
So if i don't use this parameter, all works fine, because then a Cookie with the sid is set, which is needed by the userTracking-function.
If there exists a list with know useragents which will work with this parameter, u could use this parameter while comparing useragent with this list.

Regards Ortwin
Man muss nicht alles wissen,
man muss nur wissen wo es steht

** FAQ CMS Contenido (powered by phpMyFAQ) ** - ** Forum CMS Contenido ** - ** DCEonline ** - ** DevBlog **

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Sun Feb 07, 2010 2:39 pm

Hi,

I fixed this in 2.6.2 by removing the last two parameters of setcookie().

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

RWarnecke
Posts: 68
Joined: Sat Oct 10, 2009 5:57 pm
Location: Stuttgart
Contact:

Re: online users counter going mad. (or cookie handling)

Post by RWarnecke » Wed Feb 24, 2010 8:02 am

Hello,

I have the same problem. When I remove the two last parameters, that has no effect. What can I do ?
Gruß

Rolf Warnecke

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Wed Feb 24, 2010 8:06 am

Hi,

upgrade to 2.6.2 and everything will be fine. :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

RWarnecke
Posts: 68
Joined: Sat Oct 10, 2009 5:57 pm
Location: Stuttgart
Contact:

Re: online users counter going mad. (or cookie handling)

Post by RWarnecke » Wed Feb 24, 2010 8:13 am

I have upgrading from 2.5.4 to 2.6.2. Look at Code-Orakel
Gruß

Rolf Warnecke

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Wed Feb 24, 2010 8:24 am

Hi,

strange... how does your method setCookie() in inc/Session.php look like?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

RWarnecke
Posts: 68
Joined: Sat Oct 10, 2009 5:57 pm
Location: Stuttgart
Contact:

Re: online users counter going mad. (or cookie handling)

Post by RWarnecke » Wed Feb 24, 2010 8:33 am

Code: Select all

    public static function setCookie($sessionId)
    {
        setcookie(
            PMF_COOKIE_NAME_SESSIONID,
            $sessionId, 
            $_SERVER['REQUEST_TIME'] + PMF_SESSION_EXPIRED_TIME,
            dirname(dirname(__FILE__)),
            $_SERVER['HTTP_HOST'],
            false);
    }
This is the actually function. When I set a comment to the two last parameters in the function, that has no effect. Ihave tested with PHP 5.2.10. When you need more Infos about the php installation on the server, use this link.
Gruß

Rolf Warnecke

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Wed Feb 24, 2010 8:35 am

Hi,

could you please try to remove the last parameter?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

RWarnecke
Posts: 68
Joined: Sat Oct 10, 2009 5:57 pm
Location: Stuttgart
Contact:

Re: online users counter going mad. (or cookie handling)

Post by RWarnecke » Wed Feb 24, 2010 8:45 am

I have remove the last two parameters. It's online.
Gruß

Rolf Warnecke

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Wed Feb 24, 2010 8:01 pm

Hi,

very strange... I'll check this issue.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

pommesfritz
Posts: 17
Joined: Mon Mar 01, 2010 2:59 pm

Re: online users counter going mad. (or cookie handling)

Post by pommesfritz » Wed Mar 03, 2010 2:59 pm

hi, i experienced the same problem under 2.6.3.

the setCookie in inc/Session.php in 2.6.3 looks like this:

Code: Select all

 public static function setCookie($sessionId)
    {
        setcookie(
            PMF_COOKIE_NAME_SESSIONID,
            $sessionId, 
            $_SERVER['REQUEST_TIME'] + PMF_SESSION_EXPIRED_TIME,
            dirname($_SERVER['SCRIPT_NAME']),
            $_SERVER['HTTP_HOST']);
    }
i modified it to this: (equals 2.5.6.)

Code: Select all

  public static function setCookie($sessionId)
    {
        setcookie(
            PMF_COOKIE_NAME_SESSIONID,
            $sessionId, 
            $_SERVER['REQUEST_TIME'] + PMF_SESSION_EXPIRED_TIME);
    }
i have no php knowledge and i dont even know what i did there, but it works fine :D
Last edited by pommesfritz on Wed Mar 03, 2010 3:03 pm, edited 1 time in total.

Thorsten
Posts: 14897
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: online users counter going mad. (or cookie handling)

Post by Thorsten » Wed Mar 03, 2010 3:00 pm

Hi,

with which browser did you have this issue?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

pommesfritz
Posts: 17
Joined: Mon Mar 01, 2010 2:59 pm

Re: online users counter going mad. (or cookie handling)

Post by pommesfritz » Wed Mar 03, 2010 3:05 pm

firefox AND internet explorer. both showed the same problem.

but one little thing is left. i use the german version and sometimes the counter shows 'user' instead of 'Besucher' ..

Post Reply