Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

odoo 8 automatic logout / session expiry after 10 min if browser is ideal

By
Ali Ravani
on 6/3/15, 4:50 PM 1,369 views

Hello,

odoo 8 automatic logout / session expiry after 10 min if browser is ideal.

Thanks in advance... 

2

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 6/3/15, 5:22 PM

See (and modify) method session_gc in http.py, like this:

def session_gc(session_store):
if random.random() < 0.01: ###!!! 0.001:
# we keep session one week
last_week = time.time() - 60*10 ###!!! 60*60*24*7
for fname in os.listdir(session_store.path):
path = os.path.join(session_store.path, fname)
try:
if os.path.getmtime(path) < last_week:
os.unlink(path)
except OSError:
pass

@zbik,

Thanks for the code, it's very useful. Do you have any suggestions on how this code might be modified so that no core files are modified?

I think this would be incredibly useful as a standalone module, and this would allow it to be upgrade proof as well.

Luke Branch
on 6/4/15, 2:03 AM

Hello zbik, Can you please explain excatly what modify i need to do to set 10 min logout...?? Thanks.

Ali Ravani
on 6/4/15, 2:23 AM

Answer updated

zbik
on 6/4/15, 3:25 PM

Hello zbik, Thanks for your answer, i test this code its work fine. but only 1 time it work, after i updated the code and restart the server it work, now its not working. can you please help me, what i am missing... Thanks.

Ali Ravani
on 6/8/15, 3:50 PM

After update Odoo code from repository file http.py (and method session_gc) is replaced and set as original.

zbik
on 6/8/15, 3:58 PM

I replace the code as you post in answer, and first time its work for testing i put for 1 min. so, its should logout after 1 min if browser is ideal, after logout first time in 1 min, i login again and then now its not logout...

Ali Ravani
on 6/8/15, 4:11 PM

Random set, such as 0.1 or 1.0 and tests (0.1 - in this case an average of 10 refreshes generates log off), the logout time is set to 10 minutes.

zbik
on 6/8/15, 4:47 PM

Thanks zbik

Ali Ravani
on 6/8/15, 5:37 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 6/3/15, 4:50 PM
Seen: 1369 times
Last updated: 6/9/15, 2:04 AM