Page 1 of 1

can i delete session table data

Posted: Sat Dec 23, 2017 8:24 pm
by sandeepmishra83
Hi i am using opencart 3.0.2.0.. what is use of session table data. can i delete this data.
will it create any issue further or old orders/customer details will be changed.

Re: can i delete session table data

Posted: Sat Dec 23, 2017 10:39 pm
by straightlight
I would not suggest to manually truncate the session data. There's already an hourly set interval period to handle the sessions from the core.

Re: can i delete session table data

Posted: Sun Feb 18, 2018 12:18 pm
by fairmount
Hi,

Can I ask which part of the code handles this hourly clearance? OR is there a setting in Admin? The number of records in my OC3 session table is over 100,000 and I get only three or four visitors per day and this is over a span of just 3 months.

The site is really slow with just OC3, Journal, Openstock and vqmod installed.

Thanks.

Re: can i delete session table data

Posted: Sun Feb 18, 2018 10:53 pm
by straightlight
Use TextCrawler to track lines of codes in OC. You don't need to ask the forum for these types of inquiry.

Re: can i delete session table data

Posted: Mon Feb 19, 2018 6:32 am
by fairmount
Hi Straightlight,

Thanks for the response. If I know which code to search for, I would have. I do not know which part of code within OC manages the session data database to search and hence the question. Apologies if this seems obvious, just a newbie here.

I am presuming that some part of php code within OC will go through the session table in the database and clear all the old ones. Correct me if wrong. I want to know which file within OC, Or part of the code within OC handles this os that I can check if that bit is correct in my setup.

I use use GrepWin for searching within OC, is textcrawler better than this? Will give it a go anyway.

Regards,
KG

Re: can i delete session table data

Posted: Fri May 11, 2018 7:59 am
by d3z1gnr
How did you go KG? Was looking at this subject myself this morning.

fairmount wrote:
Mon Feb 19, 2018 6:32 am
Hi Straightlight,

Thanks for the response. If I know which code to search for, I would have. I do not know which part of code within OC manages the session data database to search and hence the question. Apologies if this seems obvious, just a newbie here.

I am presuming that some part of php code within OC will go through the session table in the database and clear all the old ones. Correct me if wrong. I want to know which file within OC, Or part of the code within OC handles this os that I can check if that bit is correct in my setup.

I use use GrepWin for searching within OC, is textcrawler better than this? Will give it a go anyway.

Regards,
KG

Re: can i delete session table data

Posted: Thu Jun 28, 2018 11:44 pm
by exit15
Running 3.0.2.0 I had 450,000 records in one website and 1 MM lines in another. So I made a copy and truncated the table just to see what happens . Everything is working just fine. The question is weather the hourly cleanup process is in fact working. Clearly there are expired session records in the table. Any Idea??

Re: can i delete session table data

Posted: Mon Dec 17, 2018 4:18 am
by nongetjie
fairmount wrote:
Sun Feb 18, 2018 12:18 pm
Hi,

Can I ask which part of the code handles this hourly clearance? OR is there a setting in Admin? The number of records in my OC3 session table is over 100,000 and I get only three or four visitors per day and this is over a span of just 3 months.

The site is really slow with just OC3, Journal, Openstock and vqmod installed.

Thanks.
Hi, did you ever find a solution for this? I'm experiencing this right now :-(

Re: can i delete session table data

Posted: Mon Dec 17, 2018 4:18 am
by nongetjie
exit15 wrote:
Thu Jun 28, 2018 11:44 pm
Running 3.0.2.0 I had 450,000 records in one website and 1 MM lines in another. So I made a copy and truncated the table just to see what happens . Everything is working just fine. The question is weather the hourly cleanup process is in fact working. Clearly there are expired session records in the table. Any Idea??
Hi did you find a solution for this?

Re: can i delete session table data

Posted: Sun Dec 30, 2018 3:51 am
by exit15
I did not. If fact it is a bug (check github). The system simply does not delete old session and as a result there are thousands of OC databases inflated with millions of expired records in the 'session' table. For the time being every week or so I manually delete an avg of 150,000 records with this query:

"delete from `session` where `session`.expire < DATE_SUB(NOW(), INTERVAL 1 DAY);" (Removes everything older than 1 DAY, you can write '3 HOURS' if you prefer)

Daniel suggested a few fixes when alerted to the issue, but they did not work for me because the code on github is very different than the official distribution and every-time I copied a file that he changed to resolve this problem, it created a new problem. I am not a programmer, but i wish we could just plug the above query somewhere and simply delete old sessions

Re: can i delete session table data

Posted: Sun Jan 13, 2019 6:56 pm
by rpmb
exit15 wrote:
Sun Dec 30, 2018 3:51 am
I did not. If fact it is a bug (check github). The system simply does not delete old session and as a result there are thousands of OC databases inflated with millions of expired records in the 'session' table. For the time being every week or so I manually delete an avg of 150,000 records with this query:

"delete from `session` where `session`.expire < DATE_SUB(NOW(), INTERVAL 1 DAY);" (Removes everything older than 1 DAY, you can write '3 HOURS' if you prefer)

Daniel suggested a few fixes when alerted to the issue, but they did not work for me because the code on github is very different than the official distribution and every-time I copied a file that he changed to resolve this problem, it created a new problem. I am not a programmer, but i wish we could just plug the above query somewhere and simply delete old sessions
Thanks for this. I used the sql query you posted and used it to create a php script out of the public_html directory and then set a cron job to run it daily removing old sessions. Seemed to be the easiest automated way to prune the sessions.

Re: can i delete session table data

Posted: Sat Mar 02, 2019 1:46 am
by thbr02
rpmb wrote:
Sun Jan 13, 2019 6:56 pm
exit15 wrote:
Sun Dec 30, 2018 3:51 am
I did not. If fact it is a bug (check github). The system simply does not delete old session and as a result there are thousands of OC databases inflated with millions of expired records in the 'session' table. For the time being every week or so I manually delete an avg of 150,000 records with this query:

"delete from `session` where `session`.expire < DATE_SUB(NOW(), INTERVAL 1 DAY);" (Removes everything older than 1 DAY, you can write '3 HOURS' if you prefer)

Daniel suggested a few fixes when alerted to the issue, but they did not work for me because the code on github is very different than the official distribution and every-time I copied a file that he changed to resolve this problem, it created a new problem. I am not a programmer, but i wish we could just plug the above query somewhere and simply delete old sessions
Thanks for this. I used the sql query you posted and used it to create a php script out of the public_html directory and then set a cron job to run it daily removing old sessions. Seemed to be the easiest automated way to prune the sessions.
Would you mind share the script? I'm in the same situation and it would be nice solving it with cron.

Re: can i delete session table data

Posted: Sat Nov 02, 2019 4:45 pm
by pm-netti
This is big bug from Opencart.

My friend was 2.5 million lines in table over two years. Very few online retailers have the skill to use cron.
This should be set on the admin page where you can set the duration of the session.
-peku-

Re: can i delete session table data

Posted: Sat Nov 02, 2019 5:29 pm
by letxobnav
just use files to store sessions and php will handle it in stead of OC.

Re: can i delete session table data

Posted: Sat Nov 02, 2019 7:07 pm
by pm-netti
letxobnav wrote:
Sat Nov 02, 2019 5:29 pm
just use files to store sessions and php will handle it in stead of OC.
File system/config/default.php:

Code: Select all

$_['session_engine']       = 'db';
Why this is default setting 'db', because that recording sessions on a data insert to database is an "unfinished project" and unstable for the functioning of the trade? Can that "eternal session" jeopardize Opencart Online Stores for hacker attacks?

Re: can i delete session table data

Posted: Sat Nov 02, 2019 7:27 pm
by letxobnav
That is set to "db" because some guy in OC development probably read some article somewhere about storing sessions in databases and thought "why the hell not? Let's see if that works. Surely we can do better than native php session handling, besides, files are boring and databases are cool!"

That is how most functionality in OC, already working perfectly, is implemented again just in a different way.