问题1:但是我用php写了如下代码,访问该页面是在目录C:\Users\lumotuwe\AppData\Local\Microsoft\Windows\Temporary Internet Files找不到对应的cookie文件。
1234 | <?php setcookie( "test" , "hkjh" ,time()+3600*24*30, "/" , "www/localhost.com" ) ?> <a href= "page2.php" >Next page</a> |
问题2:session中的session.cookie_lifetime默认为0,我利用session_set_cookie_params()修改了其中的lifetime。但是当我关闭浏览器后利用test2.php,在获取session ID时获取失败。
test1.php
1234567891011 | <?php $lifetime =3600; session_set_cookie_params( $lifetime ); session_set_cookie_params( $path ); session_start(); $_SESSION [ 'sess_var' ] = "Hello world!" ; echo 'The content of $_SESSION[\'sess_var\'] is ' . $_SESSION [ 'sess_var' ]. '<br />' ; ?> |
test2.php
123456 | <?php session_start(); echo 'The content of $_SESSION[\'sess_var\'] is ' . $_SESSION [ 'sess_var' ]. '<br />' ; ?> |
获取失败的页面提醒:
Notice: Undefined index: sess_var in D:\xampp\htdocs\test\22\page2.php on line 5
The content of $_SESSION['sess_var'] is