સેશન ম્যানેજમેન્ટ વપરાશકર્તાઓને વિનંતીઓ પર લૉગ ઇન રાખવાનું સંચાલન કરે છે — અને તે સુરક્ષિતરીતે કરવું મહત્વપૂર્ણ છે, કારણ કે સેશન મુશ્કેલીઓ (હાઇજેકિંગ, ફિક્સેશન) હુમલાખોરોને વપરાશકર્તાઓનું મનપણ કરવા દે છે. સુરક્ષિત સેશન્સમાં યોગ્ય ટોકન હેન્ડલિંગ, કુકી સુરક્ષા, અને જીવનચક્ર સંચાલન સામેલ છે.
સેશન્સ કેવી રીતે કાર્ય કરે છે
After login, the server keeps a SESSION identifying the user across requests:
→ a SESSION ID (or token) is stored client-side (usually a cookie) and sent each request
→ the server uses it to know who the user is (without re-authenticating each time)
→ the session ID/token is effectively a key to the user's account → must be PROTECTED.
સેશન્સને સુરક્ષિત કરવું
✓ SECURE COOKIE flags for session cookies:
→ HttpOnly → JavaScript can't read it (protects against theft via XSS)
→ Secure → sent only over HTTPS (not plaintext)
→ SameSite → not sent on cross-site requests (mitigates CSRF)
✓ Strong, RANDOM, unpredictable session IDs (can't be guessed)
✓ Store session data server-side (or sign/encrypt tokens); transmit over HTTPS only
