quickhac / qhac-common

Common libraries for use in QuickHAC applications
3 stars 1 forks source link

Add method to check if session has expired #17

Open patil215 opened 10 years ago

patil215 commented 10 years ago

Currently, there isn't a simple way to check if a session has timed out. A method to easily check for session validity would be a helpful improvement.

tristanseifert commented 10 years ago

You might want to keep the time of the last request around, and we can make an assumption that the session expires after ten minutes. It's probably more, but this is a conservative estimate.

Then, when making a request, check the time differential, and if it exceeds a certain amount of time, you could log in again.

Alternatively, do a HEAD request to the gradebook URL, and see if that returns a 500 (RRISD) or some other error code for AISD. That's the sure-fire way of knowing if you're logged in or not, saves bandwidth, and is quite fast. (This is what the iOS app does.)

patil215 commented 10 years ago

That was actually the way I was gonna implement it if this wasn't plausible! On Jan 29, 2014 10:15 PM, "Tristan Seifert" notifications@github.com wrote:

You might want to keep the time of the last request around, and we can make an assumption that the session expires after ten minutes. It's probably more, but this is a conservative estimate.

Then, when making a request, check the time differential, and if it exceeds a certain amount of time, you could log in again.

Alternatively, do a HEAD request to the gradebook URL, and see if that returns a 500 (RRISD) or some other error code for AISD. That's the sure-fire way of knowing if you're logged in or not, saves bandwidth, and is quite fast. (This is what the iOS app does.)

Reply to this email directly or view it on GitHubhttps://github.com/quickhac/qhac-common/issues/17#issuecomment-33659018 .