[SOLVED] ‘Error at offset’ error in unserialize()

I came across this weird error in unserialize() where it refused to unserialize the serialized data. After hours of trying different things to solve it, finally converting the encoding worked.

The solution to the problem is to use the following function instead of unserialize():

function safe_unserialize($str){
       return unserialize( trim( mb_convert_encoding( $str,'auto','UTF-8' ) ) );
}

Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *