Post by swf1200 » Tue Jul 24, 2018 7:20 pm

Hi,
in version 3 OC insert session data in database or file. Now for many many user session data How do delete old session from database Or file?

Thanks

Newbie

Posts

Joined
Tue Jul 24, 2018 7:17 pm

Post by straightlight » Wed Jul 25, 2018 12:42 am

Automatically deleted after 1 hour by default.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by swf1200 » Wed Jul 25, 2018 1:10 pm

Sure?? I check session code:
After 1 Hours: session is destroy and generate new session id and insert new session in database. this true. But Old session Not Delete From Database after 1 hours. Please see my image test in Mamp localhost example:

https://pasteboard.co/Hw2IodY.png

U can see
2018-07-23
2018-07-24
2018-07-22
And New Session For Today 2018-07-25

OC Not Delete Old Session Data Form Database After Expire. and this problem when we have many many user request for website per day.

Thanks For Any Help.

Newbie

Posts

Joined
Tue Jul 24, 2018 7:17 pm

Post by ostechnologies » Wed Jul 25, 2018 7:31 pm

Not sure about this solution but you can try this out
Create a backup of session table then perform a query that will delete the data till last month.
Since these sessions are already expired, so it should not create any issue.

Opencart Expert | sales[at]ost.agency
Skype - manish.osuniverse | Gtalk - manishmt

Extensions for Opencart @ https://www.ost.agency/product/product- ... extensions
ost.agency - ecommerce website design, development and digital company


User avatar
Active Member

Posts

Joined
Mon Apr 06, 2015 1:30 pm

Post by swf1200 » Wed Jul 25, 2018 8:03 pm

ostechnologies wrote:
Wed Jul 25, 2018 7:31 pm
Not sure about this solution but you can try this out
Create a backup of session table then perform a query that will delete the data till last month.
Since these sessions are already expired, so it should not create any issue.
For 489000 Views in month ?! I delete manually ?! I think This Not Good Idea.

You work with OC 3.0 ?! If Yes, Your Session Data Remove after 1 hours? If, No Whats your solution For Big Website?!

Newbie

Posts

Joined
Tue Jul 24, 2018 7:17 pm

Post by straightlight » Wed Jul 25, 2018 9:12 pm

This wasn't considered before but I do realize a flaw in the validation here … the session table will only be cleared after one hour if the admin user uses the API with a requested route by having a valid IP address … however, it does not seem to validate whenever a session overall has exceeded one hour in order to free the database despite the API sessions or not since an admin user can simply interrupt his session without logging out from his account … besides, an API transaction should not usually an hour to complete its operation nor should the admin would require that mount of time to do so ...

Let's try the following to see if that will resolved the issue. In catalog/controller/startup/session.php file,

find:

Code: Select all

$this->session->start($session_id);
add below:

Code: Select all

$this->db->query("DELETE FROM `" . DB_PREFIX . "api_session` WHERE TIMESTAMPADD(HOUR, 1, date_modified) < NOW()");
This will still validate hourly. See if the session table does get cleared afterwards. You can also reduce the time period from: HOUR to MINUTE and 1 to let's say: 30 (30 mins). However, it would be more suggested to leave it as is with the hour period.

The only downside of this modification is the un-synchronous time period between the catalog and the admin user while using the session ID while the admin user uses the customer's account.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 12 guests