Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found a flaw in your implementation which results in deleting any session data:</p> <pre><code>return $this-&gt;stmt-&gt;fetchAll(); </code></pre> <p>in </p> <pre><code>public function Read($sessionsId) </code></pre> <p>That function <em>must</em> return a string, in your case the data from the <code>data</code> field.</p> <p>But you're returning an array (as it looks like - can't specifically say because the actual database is hidden, PDO/MySQLi?).</p> <p>However it's highly likely that unserializing the session data (see <code>session_decode()</code>) will fail, hence the session data will become empty and then saved again (as an empty string).</p> <p>This should be the cause of your problem. Fix it by returning the string data from the database.</p> <hr> <p>Next to that I suspect a kind of encoding issue but I'm not entirely sure that this causes it. But just consider the following:</p> <p>The session data is <em>binary</em> data, not <em>text</em>. You could change your table definition and access accordingly. In MySQL there is the <a href="http://dev.mysql.com/doc/refman/5.0/en/blob.html" rel="nofollow"><code>BLOB</code> Type</a> for that, and <a href="http://php.net/manual/en/pdostatement.bindparam.php" rel="nofollow"><code>bindParam()</code></a> could be helped with <code>PDO::PARAM_LOB</code> data type specifier.</p> <p>Probably this type of change will cure your issue. Otherwise it will make sure that you store the data un-altered which is what you want in any case. Stick to binary-safe handling for session data.</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