httpOnly cookie flag support in PHP 5.2
http://ilia.ws/archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html
Thanks to a patch from Scott
MacVicar that I've just applied to CVS, PHP 5.2 will have support for
httpOnly cookie flag. This neat little feature allows you to mark a
newly created cookie as HTTP only, another words inaccessible to
browser based scripting languages such as JavaScript. This means it
would become far more difficult, if not impossible to steal a user's
cookie based session by injecting JavaScript into a page and then using
to read cookies.
This flag can be toggled by passing TRUE as the 7th parameter to the
setcookie() and the setrawcookie() functions respectively. Ex:
PHP:
<?
php
setcookie
(
"abc"
,
"test"
,
NULL
,
NULL
,
NULL
,
NULL
,
TRUE
);
setrawcookie
(
"abc"
,
"test"
,
NULL
,
NULL
,
NULL
,
NULL
,
TRUE
);
?>
The support of the httpOnly flag extends to the session extension as
well, where it can be enabled by setting the session.cookie_httponly
INI setting to 1. Or passing TRUE as the 5th parameter to the
session_set_cookie_params() function.
PHP:
<?
php
ini_set
(
"session.cookie_httponly"
,
1
);
// or
session_set_cookie_params
(
0
,
NULL
,
NULL
,
NULL
,
TRUE
);
?>
Unfortunately, at this time according to my tests no other browser has
adopted this rather handy feature, but with the continual increase of
XSS attacks, I am sure they'll adopt this concept soon.
For people using PHP 4 and PHP 5.1 you can add this flag yourself by
sending cookies manually via the header function and prefixing the
;httpOnly flag to the cookie as shown in the example below:
PHP:
<?
php
header
(
"Set-Cookie: hidden=value; httpOnly"
);
?>
相关文档:
function poster()
{
$URL = 'http://www.yw56.com.cn/DIY.asp'; //需要提交到的页面
//下面这段是要提交的数据
$post_data['orderid'] = "YW861736303CN";
$post_data['button'] = "提交";
$referrer="http://www.yw56.com.cn/DIY.asp";
$Cookie=&qu ......
我们的电话报名系统中,呼叫中心收集了用户的银行信息,然后请求银行的支付接口的webservice,需要进行超时设置,因为不能一直让学员等待
解决方法是
1:首先先要看一下php.ini里的默认超时时间,一般是120秒
2:在php代码里加上
ini_set('default_socket_timeout', 10);//设置超时时间
如下图
......
基础题:
1.表单中 get与post提交方法的区别?
答:get是发送请求HTTP协议通过url参数传递进行接收,而post是实体数据,可以通过表单提交大量信息.
2.session与cookie的区别?
答:session:储存用户访问的全局唯一变量,存储在服务器上的php指定的目录中的(session_dir)的位置进行的存放
cookie:用来存储连续 ......
tidy 是一个非常帮忙的网页代码分析和纠错的工具,能够支持多种页面编码,并且支持xhtml输出。如果我们偷懒,甚至可以将整个页面缓存,最后采用tidy处理,最后输出完美的xhtml代码。
linux下安装过程如下:
首先安装tidy ,下载tidy源代码:
cvs -d:pserver: anonymous@tidy.cvs.sourceforge.net 为防备电子邮件地址收集 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> TEST </title>
<meta name="generator" content="editplus" />
......