CLIENT:
start_session()
creates a cookie (by default): Name: PHPSESSID; Content: 1q2w3e4r5t; Domain: '/'; Expires:...
SERVER:
It also creates a file stored in (my case): /var/lib/php/sessions
. Call that in there: sess_1q2w3e4r5t
. (Absolute path: /var/lib/php/sessions/sess_1q2w3e4r5t
)
So we have two physical things that are bonded to the session I just created.
What is the point of having both?
Can I just store my session in
/var/lib/php/sessions
regardless ofuse_only_cookies
option?I have a classic example with a
$_SESSION['counter']
variable. Meaning that, every time I reload theexample.php
page, the$_SESSION['counter']
increments (++
) by one. So, on the loop of pressing theF5
button, lets say I got55
as the value of$_SESSION['counter']
. Finally I its that cookie but not the/var/lib...
file. After that deletion I get a56
and the loop continues as normal. This just intrigued me and got me with the question. Are session cookies necessary?Is still possible a way in which my site just stores session only in the server and not using cookies?
This is how I deleted the cookie. notice counter
value is 69.
Then F5
: