* Get session from the store. * @param id Session ID
(id: string)
| 681 | * @param id Session ID |
| 682 | */ |
| 683 | private getSession(id: string) { |
| 684 | const sess = this.sessions[id] |
| 685 | |
| 686 | if (!sess) return |
| 687 | |
| 688 | const sessJSON = JSON.parse(sess) |
| 689 | |
| 690 | if (sessJSON.cookie) { |
| 691 | let expires: Date |
| 692 | if (!(sessJSON.cookie.expires instanceof Date)) expires = new Date(sessJSON.cookie.expires) |
| 693 | else expires = sessJSON.cookie.expires |
| 694 | |
| 695 | if (expires && expires <= new Date(Date.now())) { |
| 696 | delete this.sessions[id] |
| 697 | return |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | return sessJSON |
| 702 | } |
| 703 | } |