I keep finding exactly the wrong information that I need on sessions. I am trying to make it so that the MODX session is closed when the window is closed (or at least when the browser is quit). Is there a way to do this? We have a multi-stage form and are using sessions to carry data across several pages. The problem right now is that when an end user decides to quit in the middle of the form, all of their (sensitive) data is still there when you relaunch the browser.
Can this be done?! Is there at least a way I can set the session to time out after say 10 or 20 minutes (and destroy the data)?
MODX 2.2.4 ... I hate asking for this type of question that I could probably figure out on my own given a little time, but I have been developing for 18 hours straight now (and brain-fried) and I'm under the gun to get this thing out the door. Any little help would be appreciated!
-
☆ A M B ☆
- 24,524 Posts
There's a few ways you can do this.
1. Session garbage collection - since Revo saves the session in the database, you can make a plugin to remove the session if the user comes in again after x amount of time. See "endSession" here
http://api.modx.com/revolution/2.1/_model_modx_moduser.class.html
2. Javascript - do like the manager does, and flag a form as "dirty" if the user has put anything in it, and when he leaves the page without properly submitting to move on, have a popup to ask if he wants to leave the page like that, and if he clicks "yes" then empty the fields. I think you can also do some rudimentary cookie manipulation with Javascript as well.
I'm sure there are other ways of handling this, but these two come to mind just now.
After a sound night's sleep and some consideration, I think we are going to go with a low session timeout (2-3 minutes) with a keep-alive javascript pinging a blank page in the background every minute or so.
That raises another question... is there an easy way to set separate session times for the manager vs the web context? I dread having to work in the manager with a 2 minute timeout.
is there an easy way to set separate session times for the manager vs the web context?
Absolutely! Context Settings may override System Settings. So set the System Setting high, but open the Context (click on it). Click on Settings Tab. Create a Setting of the same exact name and type. Set to a lower number.
Note: If you really wanna break your brain with the coolness that is Settings, you can even override Context Settings by making User Settings (no, not extended fields). This way YOU can have a high setting, but everyone else has to log in after 1 minute.
The above example is not funny on April Fool's.
Context settings. [facepalm]
Derp. ... where's my dumb hat?