Protect what matters – even after you're gone. Make a plan for your digital legacy today.
Forum Discussion
cliKing
4 years agoOccasional Contributor
How to check if a session is active? (feature request)
In shell scripts I want to check that a session is active and valid and that it will still be active for the next x minutes.
The only output I need is an exit code: 0 or 1
AFAIK there is no bui...
andi_t_1P
1Password Team
4 years agoHi cliKing , so to confirm, what you are asking is a command that tells you for how many minutes will your current session still be active. If you would just like to find whether a session is still active or not op whoami should actually do the trick and it gives the same but cleaner answer about whether you are still in an active session than op vault list, and is pretty fast. op user get --me will show you when your last authentication was done but this is not deterministic for when your session will expire since the session is active for around half an hour since the last command you executed (for biometric unlock is 10 minutes), and not since your last sign in/authentication.
So in order to determine for how many minutes you session will still be active, it's a matter of executing op whoami, and then if it succeeds, it will let you know that you do have a valid active session, and also you will know that this session will be active for 30 more minutes (or 10 if you are using biometric unlock) from that point on, since you just executed a command (op whoami). Otherwise, you need to sign in again, and then you will also know that your current session will last 30/10 more minutes.
Let me know if you have further questions. All the best,
Andi