1

I want transfer magento session storage from database to files.

I want to know how to do this.

What i did is, download [BLOB - 3.6 KiB] file from database core_session table for session and rename it with sess_frontend_session_id like sess_n7g9t1872co23p0btnbos921c4

and then upload file to var/session but it's not working

Cart data is lost for not logged in customers.

asked Jul 25, 2017 at 5:52
1
  • Having same issue Commented Jul 25, 2017 at 5:57

1 Answer 1

2

Finally find the solution to transfer session data from database to files

You can run following script to transfer session data from database to files

<?php
ini_set('memory_limit', '500M');
ini_set('max_execution_time', 0);
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
require_once 'app/Mage.php';
umask(0);
Mage::app();
 $resource = Mage::getSingleton('core/resource');
 $readConnection = $resource->getConnection('core_read');
 $table = $resource->getTableName('core/session');
 $query = 'SELECT * FROM ' . $table;
 $session = $readConnection->fetchAll($query);
 $filePath = 'var/session/';
 foreach ($session as $sess) {
 $file = $filePath.'sess_'.$sess['session_id'];
 $fp = fopen($file, 'w');
 fwrite($fp, $sess['session_data']);
 fclose($fp);
 chmod($file, 0777);
 }
?>
answered Jul 25, 2017 at 13:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.