note 85066 added to function.session-set-save-handler

From: Date: Wed, 13 Aug 2008 13:31:25 +0000
Subject: note 85066 added to function.session-set-save-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-143446@lists.php.net to get a copy of this message
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 ---- Server IP: 87.124.64.96 Probable Submitter: 193.128.117.15 ---- Manual Page -- http://www.php.net/manual/en/function.session-set-save-handler.php Edit -- https://master.php.net/note/edit/85066 Del: integrated -- https://master.php.net/note/delete/85066/integrated Del: useless -- https://master.php.net/note/delete/85066/useless Del: bad code -- https://master.php.net/note/delete/85066/bad+code Del: spam -- https://master.php.net/note/delete/85066/spam Del: non-english -- https://master.php.net/note/delete/85066/non-english Del: in docs -- https://master.php.net/note/delete/85066/in+docs Del: other reasons-- https://master.php.net/note/delete/85066 Reject -- https://master.php.net/note/reject/85066 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143446) next »