Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use cookies in Codeigniter

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.38k
    Comment on it

    Hello Reader's if you are making the auto login sign up form then you must have to use the Cookies.
    In core php you have to write the long syntax to handling the request to Cookies. Now Codeingiter offers developers to load the nessasry code in pre loaded library.

    To use the Cookies you have to intitailze the helper library of Cookies, and it's code will go like this:-

    $this->load->helper('cookie');

    Now your cookies are loaded from helper liberary. And you can insert the username password in it.

    Just same as the data in session you have to set the same data in cookie also for example.

    $cookie = array(
        'name'   => 'The Cookie Name',
        'value'  => 'The Value',
        'expire' => '86500', //time in sec
        'domain' => '.yourwebiste.com',
        'path'   => '/',
        'prefix' => 'myprefix_',
        'secure' => TRUE
    );
    
    $this->input->set_cookie($cookie);

    After inserting the array values in the cookie it will remain till the time you have assing once. Now you have to make a check feature which will verify if the data in this cookie is valid then, there will the login page.
    The user now can directly navigate to it's home.

    And in case of log out, Put this code it will delete the cookie

    delete_cookie("name");

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: