session_timeout.sh

Script to test session timeout. Modify as needed.

#!/bin/bash
#------------------------------------------------------------------------
# Name        : session_timeout.sh
# Description : Test session timeout - how long it will take to timeout
# Author      : Lisandre.com
# Date        : 2022-08-10
#------------------------------------------------------------------------

URL="https://example.com/some-api"
COOKIES="session=abc"
HEADERS="Authorization: Basic whatever" # any required header
LOG="./session_timeout.txt"

echo -e "INFO: Original request on $(date)\n" > "$LOG"
curl -i --cookie "${COOKIES}" -H "${HEADERS}" "${URL}" >> "$LOG" 

for i in {1..72}; do
    echo -e "\n\nINFO: Testing $i hours\nINFO: Before request - $(date)\n" >> "$LOG"

    sleep ${i}h
    curl -i --cookie "${COOKIES}" -H "${HEADERS}" "${URL}" >> "$LOG"

    echo -e "\n\nINFO: After request - $(date)" >> "$LOG"
done

echo -e "\nINFO: End at $(date)" >> "$LOG"