Welcome Guest, Not a member yet? Register   Sign In
Read cookies values....
#1

[eluser]henry178[/eluser]
Hi!

this is code in my controller:

Code:
$cookie1 = array(
               'address' => $_POST['address'] ,
               'name' => $_POST['name'] ,
               'type' => $_POST['type'] ,
               'lang' => DEFAULT_LANGUAGE,
               'creation_date' => date('Y-m-d')
                );
                ;
                
              $this->input->set_cookie($cookie1);

                         $this->load->view('template1/form_registration2', $data);

How i can see the cookie1 i view form_registration2?

This:

<?= get_cookie('cookie1') ?>

don't work....
#2

[eluser]toopay[/eluser]
Why not using ci session? CI session is actually already using Cookie instead PHP Session.
#3

[eluser]henry178[/eluser]
[quote author="toopay" date="1310675417"]Why not using ci session? CI session is actually already using Cookie instead PHP Session.[/quote]

I want use my cookies.... any solutions?
#4

[eluser]toopay[/eluser]
One thing you should know, when you decide using general php cookie, then it will available in the next http request after you set the cookie.
So you can do something like this...
Code:
public function foo()
{
   $this->load->library('helper');
   $cookie1 = array(
               'address' => $_POST['address'] ,
               'name' => $_POST['name'] ,
               'type' => $_POST['type'] ,
               'lang' => DEFAULT_LANGUAGE,
               'creation_date' => date('Y-m-d')
   );
   setcookie('foo',serialize($cookie1));
   redirect('controllername/bar');
}
public function bar()
{
   // escape any harmfull script
   $bar = unserialize($this->input->cookie('foo',TRUE));
   var_dump($bar);
}




Theme © iAndrew 2016 - Forum software by © MyBB