How to clear session table in magneto 2

How to clear session table in magneto 2

How to clear session table in magneto 2

How to clear session table in magneto 2

How to clear session table in magneto 2 : For 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” 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

DELETE FROM session WHERE session_expires < UNIX_TIMESTAMP();


If my answer is useful, please Accept as Solution & give Kudo

Thats the funny part – tried both:

Using time() from PHP

SELECT *, DATE_FORMAT(FROM_UNIXTIME(session_expires), '%e %b %Y %H:%i:%s') FROM session WHERE session_expires >= 1550670153

Few times with above call I get one row only and my site is very active.

 

Using MySQL unix_timestamp/now

SELECT *, DATE_FORMAT(FROM_UNIXTIME(session_expires), '%e %b %Y %H:%i:%s') FROM session WHERE session_expires >= NOW()

Both of above should give me active session thats not expired but I get zero results and my page have alot of trafic all the time.

 

Thats why I’m not sure that its correct – bit it was my first approach the one you wrote about.

Checking...

Ouch! There was a server error.
Retry »

Sending message...

Enquiry Form

Fill in the form below and we will be in touch soon

Spambot blocker question

5 + 5 =




Categories

Your Future Customers Are Searching Right Now

© obeysoft. All Rights Reserved.