CodeIgniter Forums
[Solved] Codeigniter & google chrome CSRF works fine in firefox - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [Solved] Codeigniter & google chrome CSRF works fine in firefox (/showthread.php?tid=66966)



[Solved] Codeigniter & google chrome CSRF works fine in firefox - wolfgang1983 - 12-23-2016

Hi,

I have everything working so far with CSRF and fire fox.

How ever when I submit my form on google chrome my form validation error messages do not show up.

But the show up in fire fox? Any suggestions

Unless it's because CSRF is protecting form so I can only use one browser at a time?

I have attached the view

PHP Code:
$config['cookie_prefix']    'ci_';
$config['cookie_domain']    '.localhost';
$config['cookie_path']        '/';
$config['cookie_secure']    FALSE;
$config['cookie_httponly'    TRUE;

$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'my_post_key';
$config['csrf_cookie_name'] = 'cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array(); 


PHP Code:
<?php

class Newthread extends CI_Controller {

    public function 
__construct() {
        
parent::__construct();
        
$this->load->library('form_validation');
        
$this->load->model('newthread_model');
        
$this->load->helper('smiley');
    }

    public function 
index() {
        
$data['title'] = 'Newthread in ' $this->newthread_model->get_forum_title($this->uri->segment(2));

        if (
$this->input->post('preview_submit')) {
            
$data['preview'] = parse_smileys($this->input->post('message'), base_url('assets/images/smileys/'));
        } else {
            
$data['preview'] = '';
        }

 
       $data['smiley_table'] = get_clickable_smileys(base_url('assets/images/smileys/'), 'message');
        
        
$this->form_validation->set_rules('subject''subject''required');

        if (
$this->form_validation->run() == false) {

            
$this->load->view('header'$data);
            
$this->load->view('newthread'$data);
            
$this->load->view('footer');

        } else {

            if (
$this->input->post('preview_submit')) {}

            if(
$this->input->post('newthread_submit')) {

                
redirect("forum/" $this->uri->segment(2));

            }

        }
    }




RE: Codeigniter &amp; google chrome CSRF works fine in firefox - wolfgang1983 - 12-24-2016

Solution for me now both browsers work fine now.

I have had to create a vHost instead of just using normal localhost.

And then on


PHP Code:
$config['cookie_prefix']    'ci_';
$config['cookie_domain']    '.dev_project.com';
$config['cookie_path']        '/';
$config['cookie_secure']    FALSE;
$config['cookie_httponly'    TRUE



It's fun learning what works and does not. Not sure why vhost better?