在codeigniter中设置cookie

i am tring to set cookie in codeigniter but i cannt make it happen i dont know what is wrong. there is no error on the error log page...

this is my view page...

<!DOCTYPE html>
<html>
    <head>
        <title>
            EKART
        </title>
    </head>
    <body>
    <h1>SIGN IN</h1>
    <form id="admin" action="/do/ekart/adminlogin/login/" method="POST">
    Name :<br/>
    <input type="text" name="name" id="name"/><div id="name_display"></div><br/>    
    Password :<br/>
    <input type="password" name="password" id="pasword"/><div id="password_display"></div><br/> 

    <input type="submit" value="Submit"/>   
    </form>
    </body>
</html>

and here is my controller..

adminlogin.php

  <?php
    class adminlogin extends Controller{
        public function __construct(){
            parent::Controller();
            $this->load->library('mylib');
        }
        public function index(){
            $this->load->view("ekart/adminlogin");      
        }
        public function login(){
            $name=$_POST["name"];
            $password=$_POST["password"];
            $data=array("username"=>$name,"password"=>$password);
            $result=$this->mylib->logincheck($data);
            if($result){
                echo "every thing is fine";
                setcookie("myCookie",$name,time()+3600,"/");
                $this->load->view("ekart/home",array("message"=>""));
            }
        }
    }

the control is going inside if and it also prints "every thing is fine" the home page is also get loaded but i dont know why the cooke is still not set..

mylib is my library to check login validation....

There is a codeigniter way of doing this.

Make sure to have $this->load->helper('cookie'); in your controller, or autoload it.

$cookie = array(
  "username" => $name,
  "time" => time()+3600
);

$this->input->set_cookie($cookie);