<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>cookie</title>
<meta name="Generator" content="">
<meta name="Author" content="czh">
<meta name="Keywords" content="php date">
<meta name="Description" content="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
function writeCookie()
{
    var d=new Date();
    d.setTime(d.getTime()+24*60*60*365*1000);
    document.cookie="UserName="+mF.name.value+";expires="+d.toGMTString();
    document.cookie="UserSex="+mF.sex.value+";expires="+d.toGMTString();
    document.cookie="UserProvince="+mF.province.value+";expires="+d.toGMTString();
    document.cookie="UserEmail="+mF.email.value+";expires="+d.toGMTString();
    document.mF.submit();
}
</script>
</body>
pls input your infomation:
<form name="mF" method="post" action="./cookie_creat.php">
    <table>
        <tr>
            <td>name:</td>
            <td><input name="name" type="text" size=15></td>
        </tr>
        <tr>
            <td>sex :</td>
            <td><input name="sex" type="text" size=15></td>
        </tr>
        <tr>
            <td>prov:</td>
            <td>
                <select name="province">
                    <option value="1">1
                    <option value="2">2
                    <option value="3">3
                    <option value="4">4
                    <option value="5">5
                    <option value="6">6
                    <option value="7">7
                    <option value="8">8
                </select>
            </td>
        </tr>
        <tr>
            <td>E-mail:</td>
            <td><input name="email" type="text" size=25></td>
        </tr>
        <tr align="center">
            <td><input type="button" value="ok" onclick="writeCookie()"></td>
        </tr>
    </table>
</form>
</html>
<?php 
echo '<pre>';
print_r($_COOKIE);
?>

posted on 2013-04-25 17:07  vinsonLu  阅读(185)  评论(0编辑  收藏  举报