+ 2
How can I check if the user's session has expired or not?
In my Airline Booking Program, I now wish to make a session timer. I want to offer the user n minutes for booking, and then cancel booking if the user hasn't reached the last option till then... So I wish to count the number of seconds taken during the data fill... I think I have to use <chrono> for this, but I have no idea how to use it... How can I create this timer? Also, I want to print the time left in the session to end to be printed alongside in the console, n-executed time. How to display that?
8 Respostas
+ 4
as the user logs in save the time in a Session variable e.g. loginTime.
on each page load check if the current time - loginTime is greater than the timeout you want to set:
If true handle the expired session the way you prefere.
Else reset the login time assigning the current time to the loginTime variable.
+ 4
You can create use JavaScript for that.
look at setTimeout and/or setInterval.
+ 4
Sorry I thought you were doing a web interface...
The concept is the same.
have a look at time.h http://www.cplusplus.com/reference/ctime/
you can use a label to show the time value
+ 1
@seamiki
But how will I increase it after every second?
+ 1
@seamiki
JS in C++?
Is it possible?
+ 1
@seamiki
Thank You very much!
+ 1
@kinshuk did you write your code after seamiki advice.if yes then kindly give the link to your program.
well i did a program based on that but it not working properly.
https://code.sololearn.com/cpJA2R6nU1da/?ref=app
+ 1
@NIKHIL
Mine's not working as well, yet...