Parses a JSON cookie file and returns a dictionary of cookie data.
(cookie_file_path: str)
| 214 | |
| 215 | |
| 216 | def parse_cookie_file_to_dict(cookie_file_path: str) -> Dict[str, Dict[str, Any]]: |
| 217 | """ |
| 218 | Parses a JSON cookie file and returns a dictionary of cookie data. |
| 219 | """ |
| 220 | parsed_data = {} |
| 221 | |
| 222 | with open(cookie_file_path, "r") as file: |
| 223 | cookies = json.load(file) |
| 224 | |
| 225 | for cookie in cookies: |
| 226 | name = cookie.get("name") |
| 227 | value = cookie.get("value") |
| 228 | domain = cookie.get("domain") |
| 229 | path = cookie.get("path") |
| 230 | |
| 231 | if name: |
| 232 | parsed_data[name] = { |
| 233 | "value": value, |
| 234 | "domain": domain, |
| 235 | "path": path, |
| 236 | "expires": cookie.get("expires"), |
| 237 | "httpOnly": cookie.get("httpOnly"), |
| 238 | "secure": cookie.get("secure"), |
| 239 | "sameSite": cookie.get("sameSite"), |
| 240 | } |
| 241 | |
| 242 | return parsed_data |