# Session data migration from Zend to Laminas

**URL:** <https://discourse.laminas.dev/t/session-data-migration-from-zend-to-laminas/1513>\
**Category:** Migration\
**Created:** [April 8, 2020, 9:32am UTC](https://discourse.laminas.dev/t/session-data-migration-from-zend-to-laminas/1513 "2020-04-08T09:32:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian\_Rahm](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/fabian_rahm/32/585_2.png) [@Fabian\_Rahm](https://discourse.laminas.dev/u/Fabian_Rahm)\
**Post date:** [April 8, 2020, 9:32am UTC](https://discourse.laminas.dev/t/session-data-migration-from-zend-to-laminas/1513/1 "2020-04-08T09:32:44Z")

</div>

Hi

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?

Regards  
Fabian

---

<div class="post-metadata">

**Author:** ![Fabian\_Rahm](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/fabian_rahm/32/585_2.png) [@Fabian\_Rahm](https://discourse.laminas.dev/u/Fabian_Rahm)\
**Post date:** [April 15, 2020, 6:44am UTC](https://discourse.laminas.dev/t/session-data-migration-from-zend-to-laminas/1513/2 "2020-04-15T06:44:32Z")

</div>

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.

```
#!/bin/bash

# NOTE: run directly in sessions folder!

# create backup of original session files
backup=sessions.zip
if [! -f "$backup"]
then
  zip $backup sess_*
fi

# rewrite sessions
for session in `ls sess_*`
do
  sed -i -e 's/ __ZF|/__ Laminas|/' $session
  sed -i -e 's/Zend_Auth|/Laminas_Auth|/g' $session
done
```
