Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Cookies are not stored on the server at all. Those are stored in the browser and then sent to the server in the request headers. You can easily find software and plugins for browsers that allow you to create/edit/delete cookies. For that reason you should never store sensitive information in cookies. Essentially what you want to do is store the user data in a session and then store the session name in a cookie. Usually this is done automatically in php when you use the function session_start().</p> <p>If you are using Codeigniter, the php session functions are wrapped in a CI session library that is auto loaded on each page load. So instead of storing data in $_COOKIE you will want to get/set your data via the userdata method in the session library:</p> <pre><code>//in your controller //save session data $userdata = array( "isLoggedIn"=&gt;true, "username"=&gt;$_POST['username'] ); $this-&gt;session-&gt;set_userdata($userdata); //get session data later $isLoggedIn = $this-&gt;session-&gt;userdata("isLoggedIn"); if(!$isLoggedIn){ //if the user is not logged in, destroy the session and send to the login screen $this-&gt;session-&gt;sess_destroy(); redirect("/"); } </code></pre> <p>Note that the code above is not tested and is only supposed to give you an idea on where to go. If the session methods aren't working for you, you may need to load the library in manually:</p> <pre><code>//in the __construct method of your controller: $this-&gt;load-&gt;library("session"); </code></pre> <p>You can find more information here: <a href="http://ellislab.com/codeigniter/user-guide/libraries/sessions.html" rel="nofollow">http://ellislab.com/codeigniter/user-guide/libraries/sessions.html</a> and here: <a href="http://www.php.net/manual/en/book.session.php" rel="nofollow">http://www.php.net/manual/en/book.session.php</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload