What are sessions and cookies in php and where are they stored?

后端 未结 4 737
鱼传尺愫
鱼传尺愫 2020-12-21 12:16

What are sessions and cookies in php and where are they stored?

I searched but I can\'t find the exact answer.

4条回答
  •  旧巷少年郎
    2020-12-21 12:43

    Cookies are stored in the browser, not in PHP. You can get the cookies the browser sent by looking in $_COOKIE['cookiename'], but as far as i know you can't set cookies like that -- you need to use setCookie(), or possibly header('Set-cookie: ...').

    The sessions can be stored anywhere, but they're most often just files on your server's filesystem; your php.ini (or the ini_get() function) would probably be helpful in finding out where. Try:

    $session_file_name = ini_get('session.save_path')."/sess_".session_id();
    

提交回复
热议问题