about 3 years ago

測試cookie是否有用httpOnly,可這樣測試

test.js
<script>
     alert(document.cookie);
</script>

Yii可以這樣設定

protected/controllers/Controller.php
<?php
    $cookie = new CHttpCookie('cookiename', 'some value', array('httpOnly' => true));
?>
← Yii用ActiveRecord撈資料或塞資料遇到的問題 javascript escape html tag →