2016-03-23 17 views
0

Ich verwende die Ion-Auth "Bibliothek" für codeigniter (https://github.com/benedmunds/CodeIgniter-Ion-Auth) und ich bekomme ein Problem mit den Flashdata. Dies ist ein Sumary Code:Sitzung flashdata funktioniert nicht auf Formular senden

public function reset_password($code = NULL) 
{ 
    if (!$code)show_404(); 
    $this->user = $this->ion_auth->forgotten_password_check($code); 
    if ($this->user) 
    { 
     //setting the rules 
     if ($this->form_validation->run() == false) 
     { 
      //more code 
      $this->_get_csrf_nonce(); 
      /* 
       One of the things this function (_get_csrf_nonce) makes is: 
       $this->session->set_flashdata('csrfkey', $key); 
       $this->session->set_flashdata('csrfvalue', $value); 
      */ 
      //The next thing is load the view with the form 
     } 
     else //form is running 
     { 
      echo "flashdata csrfkeyvalue: ".$this->session->flashdata('csrfvalue')."<br>"; 
      die; 
      //more code, but not important by the moment 
     } 
    } 
} 

Nun, das Echo von $ this-> Session-> flashdata ('csrfvalue'), wenn das Formular Allways nichts zeigen submited ist.
Wenn ich machen so etwas wie:

private function _get_csrf_nonce(){ 
    /*$this->load->helper('string'); 
    $key = random_string('alnum', 8); 
    $value = random_string('alnum', 20); 
    $this->session->set_flashdata('csrfkey', $key);*/ 
    $this->session->set_flashdata('csrfvalue', $value); 
    redirect(base_url("auth/test")); 
    //return array($key => $value); 
} 
public function test() 
{ 
    echo "flashdata csrfkeyvalue: ".$this->session->flashdata('csrfvalue')."<br>"; 
} 

In diesem Fall ... es funktioniert. Die Ansicht, die ich zum Formular verwende, ist sehr sehr ähnlich von diesem: https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/2/views/auth/reset_password.php

Danke.

Antwort

0

SOLUTION

Nach ein wenig zu kämpfen, war ich für etwas, das eine neue Anforderung zwischen der Sicht der Form geladen machen könnte und die Form submited wurde ... endlich entdecke ich (ich Artikel nicht erinnern) ein Javascript, das Anfrage ist, obwohl ein Controller (um einige Texte zu übersetzen, basierend auf diesem Tutorial: http://www.student.kuleuven.be/~r0304874/blog/international-javascript-files-in-codeigniter.html). Ich wurde auf diese Weise geladen:

<script src="<?=site_url('jsloader/login.js');?>" type="text/javascript"></script> 

Danke.

Verwandte Themen