shochu/cookies.sh
2022-03-30 21:33:14 +02:00

13 lines
256 B
Bash

#!/bin/bash
getCookie() {
local key="$1"
echo "$HTTP_COOKIE" | tr ';' $'\n' | grep -e "^$1=" | cut -d= -f2 | sed -r 's/\s*$//g'
}
setCookie() {
local key="$1"
local value="$2"
local attributes="$3"
header "Set-Cookie" "$key=$value; $attributes"
}