I have made a cms using codeIgniter and we are facing the issue of data loss while adding and updating contents. Previously it occured while editing the data session gets expired and i got logged out . we have been using session based login . it happens randomly. also we are unable to reproduce because it happens only sometimes.we are using mysql as our database.
it happens only on our production server not on local or dev.can you guys please come up with some suggestion on this.this is really very urgent?
Sessions will automatically end after a certain period of inactivity. How long does it take before the problem occurs? Usually sessions are good for 20~24 minutes.
There are several ways you could tackle this problem:
- use ajax to refresh the session every five minutes or so while the page is being edited
- when a post is made but the user is logged out, save the data to a new session and ask the user to log back in again, after which the data is updated in the database
- use a javascript timer to countdown, and then the session is about to expire (a couple of minutes before that actually), open a popup in which the user can log back in again
The first solution is probably the easiest to implement, the second is the hardest to do. All will require quite a bit of coding to set up, but if it solves the problem then that’s OK, I guess
Oh, one more solution: set the session timeout to something silly like two hours. Not sure if this is a good idea though.