Why session_start is needed when using session?

前端 未结 4 1570
礼貌的吻别
礼貌的吻别 2021-01-01 03:05

Why I can use setcookie without any preparation while need a session_start() before using $_SESSION?And I think works they do are simi

4条回答
  •  攒了一身酷
    2021-01-01 03:58

    The session data is not necessarily stored in a file as Gordon says. With session_set_save_handler() you can define your own backend that should store the values, e.g. in a database.

    All this data retrieving is handled with session_start(). This way you can easily change you backend without breaking your application.

    Note: This is only one reason for session_start(), and again it does lot more then just setting cookies.

提交回复
热议问题