PDA

Tam Sürümünü Görmek İçin : javascript cookie


HiperAktif®
12/03/2004, 05:09
javascript ile nasıl cookie yazarım acep ?


HunTER
12/03/2004, 10:04
Suna goz atabılırsın,


<html>

<head>
<title>Cerez Islemlerı</title>
<script>
// Cerez Gonder
function SetCookie(name,value,hours)
{
var expire = "";
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
document.cookie = name + "=" + escape(value) + expire;
return true;
}

// Cerez oku
function GetCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0){
offset = document.cookie.indexOf(search);
if (offset != -1){
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}

// Cerez gonder
SetCookie('test','Merhaba !!!',1);

// Cerez oku
alert(GetCookie('test'));

// Cerezı sıl
SetCookie('test','Merhaba !!!',0);
</script>
</head>

<body>Ceviz.NET</body>
</html>

HiperAktif®
12/03/2004, 18:18
çok makbule geçti sağol

HiperAktif®
12/03/2004, 19:38
ya javascriptin oluşturduğu cookieler sadece oluşturulduğu sayfadamı okunabiliyor ?

yani
asp ile javascriptin yazdığı cookieyi okuyabiliyorum..ancak sadece o sayfayı F5 yapınca..
yani başka bir sayfada asp ile dahi o cookieyi okuyamıyorum

HiperAktif®
12/03/2004, 19:56
tamam sorun kalmadı..nasıl kalmadı bilmiyorum ama kalmadı işte :)