note 85066 deleted from function.session-set-save-handler by cmb

From: Date: Thu, 08 Sep 2016 12:25:28 +0000
Subject: note 85066 deleted from function.session-set-save-handler by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206531@lists.php.net to get a copy of this message
Note Submitter: james at dunmore dot me dot uk ---- If your using database session handler and your database is in UTF8, but you happen to have a script running in IS0-8859 that tries to put symbols such as £ signs into the database - then the session will corrupt and data will go missing. You can either - make sure you never put special characters into the session, or - more helpful, do this in your 'write' function <?php public static function write( $key, $val ) { $val = utf8_encode( $val ); $val = preg_replace( '!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $val ); //...... ?> probably an overhead on this, but less overhead than loosing data. You could also use WDDX for storing sessions I suppose

« previous php.notes (#206531) next »