When you serialize data containing text strings which have mixed line endings ("\n" and "\r\n"), unserialization often does not work. This bug is described at
To fix the issue use json_encode around serialized string:
$data_serialized = json_encode(serialize($data));
JSON format expects explicit line ending characters displayed as user readable text in form of "\n" and "\r\n".
After that decode string back and unserialize it: