Clear Magento session data stored in MySQL database

Clear Magento session data stored in MySQL database

As you probably noticed, during the installation Magento gives you different options where to store session data. The two options are File system and Database

File system is selected by default and session files are stored in var/session folder.

The other option, to store session in Database, is usually used when you are hosting Magento store on multiple web servers (cloud hosting).

If, from some reason, you need to clear all the session data, you would usually just need to clear the var/session folder. But what if the session data is stored in database? Well, then you need to “Truncate” core_session table in your Magento database. However, this will cause you to lose active sessions.

If you need to delete just the expired sessions use following MySQL query:

[codesyntax lang=”sql”]

DELETE FROM core_session WHERE session_expires < UNIX_TIMESTAMP()

[/codesyntax]

Hope this helps!

Leave a Reply

Your email address will not be published.