• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
set_cookie works in Firefox, but fails in Chrome and IE

#1
[eluser]luismartin[/eluser]
This is very weird. I've done a welcome page, so that when a new user enters the web, he/she is displayed a welcome screen and a language selector. Then the selection is sent via POST, a cookie is set and there is a redirect to the same page, and since the cookie has been created already, the user enters the homepage.

Everything works perfectly in FF, but for some reason the cookie is not being created in Chrome and IE. Cookies are enabled because the ci_session and csrf cookies are being created. What might be happening??

This is part of the code:

Code:
$cookie_lang = $this->input->cookie('myweb_language');
        if (!$cookie_lang) {
            // Still no cookie. Check whether language selection is sent
            $lang_sel = $this->input->post('lang_sel');
            if (!empty($lang_sel)) {
                $this->_create_lang_cookie($lang_sel);
            }
            else {
                // No cookie nor language selection. Display welcome screen.
                $this->_frontpage();  
            }
        }

The function _create_lang_cookie:

Code:
private function _create_lang_cookie($lang_sel) {
        $cookie = array(
                    'name'   => 'language',
                    'value'  => $lang_sel,
                    'expire' => 604800,
                    'domain' => get_domain(), // retrieves current domain name
                    'path'   => '/',
                    'prefix' => 'myweb_',
                    'secure' => false
                );
                
        $this->input->set_cookie($cookie);
        redirect(base_url() . ($lang_sel == 'es' ? '' : $lang_sel . '/'));
    }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.