fix bug :Warning: SessionHandler::read(): in Magento 2 and Cpanel

Fix bug :Warning: SessionHandler::read(): in Magento 2 and Cpanel

Warning SessionHandler::read() is a common bug that developers or clients always are faced With, in the post ‘fix bug :Warning: SessionHandler::read() in Magento 2 and Cpanel’ we are going to show how we can fix this bug. Follow us to know more about this issue and resolve it.

First of all, you need to know why warning SessionHandler::read() is happening. Where does it come from?! It’s a long story but let me shorten it: every file or folder inside the Linux OS has an owner and permission. Sometimes owner and permission will change to something that the host user does not allow to read or create the sessions. So what is going to happen? I think you have faced the issue before and you have seen what is going to happen, you will see this bug.

Warning: SessionHandler::read(): Session data file is not created by your uid in.

Related posts: SEO checklist for transfer to Magento 2

We offer you 3 ways to fix this bug :

1-set 777 permission to the session folder by   ‘chmod -R 777 session_path’ please never never never and never use 777 permission to any of the server folders. Not only it doesn’t fix your bug, but also it will give access to any user to change the folders and files. It’s so dangerous. Maybe you think “I am the only user or my server is dedicated” but It is still dangerous. Never use it.

2- Change session save mode. Open the ‘app/etc/env.php’ file and find the below links:

'session' =>
array (
'save' => 'file'

change it to :

'session' =>
array (
'save' => 'db'

It’s not a good idea to save sessions on the database because if you have a lot of customers after a while your database will be heavy. So you can do it but it’s not our recommended solution.

3: You can change the folder session to any folder that has read and write access. For example the ‘/tmp’ folder. But how we can change the session folder in the Cpanel :

Open php.ini file. (You can find it by the phpinfo() function)


Find session.save_parh and change it to /tmp/ like this


I hope after all those solutions the bug has disappeared but if not let us know. Feel free, to share your thoughts with us.