सत्र व्यवस्थापन उपयोगकर्ताहरूलाई अनुरोधहरू भर मा लगइन राखने काम गर्छ — र यो सुरक्षित रूपमा गर्नु महत्त्वपूर्ण छ, किनकि सत्र कमजोरीहरू (अपहरण, निर्धारण) आक्रमणकारीहरूलाई उपयोगकर्ताहरूको नकल गर्न दिन्छ। सुरक्षित सत्रहरूमा उचित टोकन ह्यान्डलिङ, कुकी सुरक्षा, र जीवनचक्र व्यवस्थापन समावेश छ।
सत्रहरू कसरी काम गर्छन्
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
