-1

Session is a server side variable it works in server, cookies are working in client side. I login to website the session is started, then i clear my browsing history and reload my webpage its logout and redirected to login page.
How it Works?.
How sessions automatically destroyed?

Sambhu M R
  • 297
  • 5
  • 23

3 Answers3

1

The contents of the session are stored at the server. However the session is identified by a session-id, which is stored at the client and sent with each request.

Usually the session-id is stored in a cookie, but it can also be appended to urls. (That's the PHPSESSID query-parameter you some times see)

So when you clear the browser cache, cookies are deleted(Session_ID is also deleted) and hence session variables can't be accessed.

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
1

If your server binds session with cookies for authentication purposes or checks saved cookie in each page load. And if in your browser you have set to delete cookies upon clearing browsing history, then yes it can be done, you can get logged out.

One workout is to try clearing browsing history without clearing cookies set by websites.

0

As commented, the cookie you delete tells the server who you are. Without it, you need to login in again to get a new identifying cookie.

Hectate
  • 210
  • 2
  • 9