1

In PHP, I create a session and add data to it. Then we close the browser. When I reopen the browser, can I still get that data from the session ?

Machavity
  • 30,841
  • 27
  • 92
  • 100
yunus kula
  • 859
  • 3
  • 10
  • 31

2 Answers2

4

If you want to have a user's session persist after they close the browser, please review:

session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params().

Shown at the Runtime Configuration page regarding sessions. This way, rather than the session cookie only lasting until the browser is closed, it can persist and continue on when they re-open the browser and go back to your site.

Mark Stanislav
  • 979
  • 4
  • 11
1

That depends on session's cookie parameters (if you are using built-in sessions). If expires set 0, session will expire when browser is closed. See setcookie() and session_set_cookie_params for details

Timur
  • 6,668
  • 1
  • 28
  • 37