Session data migration from Zend to Laminas


We’re about to migrate our applications using laminas-migration. Many thanks for providing this tool to the authors.

For deployment to production, we aim to keep login states of logged-in users. We’re using zend-session at the moment. All session files, are prefixed with __ZF while laminas-session will use __LAMINAS while the source does not seem to be backwards compatible at a quick glance. The content of each session file itself also carries references to Zend which needs replacement.

Is this something which has been adressed before with a tool?


For our use case (the session files are configured to reside on a file system), the following bash script does the job and a user stays loggedin after the tool laminas-migration has been used.


# NOTE: run directly in sessions folder!

# create backup of original session files
if [ ! -f "$backup" ]
  zip $backup sess_*

# rewrite sessions
for session in `ls sess_*`
  sed -i -e 's/__ZF|/__Laminas|/' $session
  sed -i -e 's/Zend_Auth|/Laminas_Auth|/g' $session
1 Like