Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems that you don't have a clear vision of sessions and cookies!</p> <p>No body can change the session contents except your code (beside attacks). So you can store everything (reasonable) like <code>user id</code> or <code>username</code> that you need to access frequently. in cookies you must store some obfuscated information that you can recognize user later when he/she tries to access your page. so based on cookie content you can regenerate users session (ie. re-login user automatically). Just to note that user CAN change cookies content so it must not be something simple like <code>user id</code> for security reason.</p> <p>I just give you a simple example, it's far from perfect but not so bad! you may need to tailor it to fit your scenario: </p> <p>here you can create cookie content like this:</p> <pre><code>$salt = substr (md5($password), 0, 2); $cookie = base64_encode ("$username:" . md5 ($password, $salt)); setcookie ('my-secret-cookie', $cookie); // and later to re-login user you do: $cookie = $_COOKIE['my-secret-cookie']; $content = base64_decode ($cookie); list($username, $hashed_password) = explode (':', $hash); // here you need to fetch real password from database based on username. ($password) if (md5($password, substr(md5($password), 0, 2)) == $hashed_password) { // you can consider use as logged in // do whatever you want :) } </code></pre> <p>UPDATE: </p> <p>I wrote <a href="http://boynux.com/consumers-system-trusted-database/" rel="nofollow">this article</a> that covers this concept. Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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