0

As weird as it sounds, I have a problem with sessions that occur only under Chrome.

Here is the scenario:

I have a method search in the controller:

public function search()
{
    $keyWord = htmlspecialchars(strip_tags($this->get['keyword']));
    if(mb_strlen($keyWord) < 3){
        $this->flashMessage->warning('keyword is too short');
        redirect(SITE_ADDR . '/forum');
    }
   ......
}

Plain and simple - if the keyword from $_GET is less than 3 characters - save a message in $_SESSION and redirect. However if I go to the search page (eg. site.com/forum/search/?keyword=fff) (note there are 3 characters in $_GET) and start refreshing really quick, the error message is randomly set BUT the redirect function is never called. I tried stopping the script by inserting exit(); right after $this->flashMessage->warning and the script was stopped with no problems but the redirect function is never called. For 1 or 2 characters, there is no problem with the redirect. Only for 3 and more characters when the error message is not even supposed to be set in a session.

This only happens in Chrome. I tried Firefox and Opera and there was no such problem. I tried in incognito but nothing changed. Anyone has any idea why is this happening?

I am not using a framework or anything.

djkhalen
  • 43
  • 1
  • 5
  • Well, I'm not seeing any code presented that has anything to do with the PHP SESSION, so its kind of hard other than to just guess. You also have not shown any code here where it clears out the warning if it should not be set (once its set, it will remain set until you clear it, or the session expires). Please provide more. – IncredibleHat Dec 11 '17 at 22:19
  • I found out why please see my second post. – djkhalen Dec 11 '17 at 22:24

1 Answers1

0

I found the reason why this is happening.. Who would have thought?

Session data lost in Chrome only

djkhalen
  • 43
  • 1
  • 5