<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test Page</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
I need script that makes cookie when i click on link and then gets me to this URL: http://tuupurid.zzl.org/library/blog/muudatest.php
Cookie name shoud be "BLOG_ID"
Cookie value should be php variable $ID(value is gotten from mysql table).
Cookie should expire after 30mins.
Cookie should work in entire domain.
<p>
<?php $ID = "someUser"; ?>
<a href='http://tuupurid.zzl.org/library/blog/muudatest.php' onclick='setCookie( "BLOG_ID", "<?php echo $ID;?>", "secs=1800", "/" )'>GO THERE</a>
<script type='text/javascript'>
function setCookie( cName, cValue, days, cPath, cDomain, cSecure )
{
var dt = new Date(),
expSecs = ( expSecs = days.toString().match( /\bsecs\s*=\s*(\d+)/i ) ) ? Number( expSecs[ 1 ] ) : 0,
params = ( days ? ( ";expires=" + new Date( expSecs ? ( dt.setTime( dt.getTime() + expSecs * 1000 ) ) : ( dt.setDate( dt.getDate() + days) ) ).toUTCString() ) : "" )
+ ( cPath ? (";path=" + cPath) : "" )
+ ( cDomain ? ";domain=" + cDomain : "" )
+ ( cSecure ? ";secure" : "" );
document.cookie = cName + "=" + encodeURIComponent( cValue ) + params;
}
</script>
</body>
</html>