Search code examples
phpsession-state

Is a session variable stored by default in a cookie?


When I use session variable for a website in PHP, is that information stored in a cookie? Or is it just on the server and it times out?

I want to store information about which usergroup and security groups a person is in so I don't have to access the database each time a page is loaded. I thought I would get all that information once, store it in a session variable, and access the variable when the page loads. No passwords, just groups.

It is an intranet application.

Thanks.


Solution

  • No, that data is not stored in a cookie, it is stored on a server. The application uses a cooke, called a session token, that is sent to the server on each request to tell the server which session belongs to which client. So the cookie allows the server to keep track.

    Storing that data in the session is just fine.