Topic: Player having to login twice, cookie error.

Hi,

I recently migrated my website from one server to another (note that the new server has a different timezone and is no longer dedicated)

I didn't had any problem before the migration, but since then players have to login twice so it works.

The first time, they have that error: "You appear to have logged in successfully, however a cookie has not been set. Please check your settings and if applicable, enable cookies".

If I open new incognito window on any browser, and then log in, I have the error, if I reoppen the website (without closing the window) it works. If I disconnect and reconnect (without closing the window) it works.

This is where the error message is triggered :

if ($forum_user['is_guest'] && isset($_GET['login']))
message($lang_common['No cookie']);

Does someone knows if I might have forgot to do something?

Thank you,
mrblimack

Re: Player having to login twice, cookie error.

It is error was in punbb 1.3 version, but in v. 1.4.4, in the current version this problem has been fixed.

3 (edited by mrblimack 2018-06-16 22:47)

Re: Player having to login twice, cookie error.

Hi,

Thank you for your answer.

I did the upgrade to 1.4.4 base on those directions: http://punbb.informer.com/forums/topic/ … ate-punbb/

But I still have the same issue.

(I also got a redirection problem on the game (not the forum). Also on the game, the header and footer where weird. On the Forum Side the pseudo of player didn't appeared on top of the Avatar)

Re: Player having to login twice, cookie error.

Check time of your server and its time zone.

ForkBB
I speak only Russian  :P

Re: Player having to login twice, cookie error.

Timezone of my server is EDT but on the php side it is GMT+2

On php side it really need to stay GMT+2

Re: Player having to login twice, cookie error.

Hi again!

I've started looking at it again since I thought I might had a lead.

In the code include/functions.php there's that part in set_default_user():

if (!defined('FORUM_QUIET_VISIT'))
    {
        // Update online list
        if (!$forum_user['logged'])
        {
            $forum_user['logged'] = time();
            $forum_user['csrf_token'] = random_key(40, false, true);
            $forum_user['prev_url'] = get_current_url(255);

            // REPLACE INTO avoids a user having two rows in the online table
            $query = array(
                'REPLACE'    => 'user_id, ident, logged, csrf_token',
                'INTO'        => 'online',
                'VALUES'    => '1, \''.$forum_db->escape($remote_addr).'\', '.$forum_user['logged'].', \''.$forum_user['csrf_token'].'\'',
                'UNIQUE'    => 'user_id=1 AND ident=\''.$forum_db->escape($remote_addr).'\''
            );

            if ($forum_user['prev_url'] != null)
            {
                $query['REPLACE'] .= ', prev_url';
                $query['VALUES'] .= ', \''.$forum_db->escape($forum_user['prev_url']).'\'';
            }

            ($hook = get_hook('fn_set_default_user_qr_add_online_guest_user')) ? eval($hook) : null;
            $forum_db->query_build($query) or error(__FILE__, __LINE__);
        }
        else
        {
            $query = array(
                'UPDATE'    => 'online',
                'SET'        => 'logged='.time(),
                'WHERE'        => 'ident=\''.$forum_db->escape($remote_addr).'\''
            );

            $current_url = get_current_url(255);
            if ($current_url != null)
                $query['SET'] .= ', prev_url=\''.$forum_db->escape($current_url).'\'';

            ($hook = get_hook('fn_set_default_user_qr_update_online_guest_user')) ? eval($hook) : null;
            $forum_db->query_build($query) or error(__FILE__, __LINE__);
        }
    }

    $forum_user['disp_topics'] = $forum_config['o_disp_topics_default'];
    $forum_user['disp_posts'] = $forum_config['o_disp_posts_default'];
    $forum_user['timezone'] = $forum_config['o_default_timezone'];
    $forum_user['dst'] = $forum_config['o_default_dst'];
    $forum_user['language'] = $forum_config['o_default_lang'];
    $forum_user['style'] = $forum_config['o_default_style'];
    $forum_user['is_guest'] = true;
    $forum_user['is_admmod'] = false;

    ($hook = get_hook('fn_set_default_user_end')) ? eval($hook) : null;
___


Now I noticed that the first time someone logged in, it is getting called twice, first time it is called, it returns false, second time it is called it returns true.

But  the second time someone logged in, it is called only once and return false.

From that point I'm lost again, if someone know the solution it would be very appreciated!

Thank you!

Re: Player having to login twice, cookie error.

Give a link to your forum.
And also login and password for the test user.

ForkBB
I speak only Russian  :P

8 (edited by mrblimack 2018-07-15 20:43)

Re: Player having to login twice, cookie error.

http://ppbo.ws/forum/

Edit : Removed test account infos

Thank you for looking into this!

Re: Player having to login twice, cookie error.

_www.ppbo.ws and _ppbo.ws are different domains.
The forum installs cookies for _www.ppbo.ws. These cookies are not visible on the _ppbo.ws domain.
Use only one domain and put cookies for it.

ForkBB
I speak only Russian  :P

Re: Player having to login twice, cookie error.

Omg I think I just understood.

I have been playing in the code changing www.ppbo.ws for ppbo.ws, everytime something worked, but something broke. And I was looking into the code trying to find the problem.

But if I understand correctly, the problem is on my domain itself which is ppbo.ws and not www.ppbo.ws, am I right? So I should either change my domain for www.ppbo.ws or change all my lines in code for ppbo.ws.

11

Re: Player having to login twice, cookie error.

https://stackoverflow.com/q/12050590

ForkBB
I speak only Russian  :P

Re: Player having to login twice, cookie error.

Thank you so much!!

I've been looking at this problem for two months!

And thank you for your patience also, I'm not a programmer so everything is new to me smile