Nasıl jQuery ile geri al çerez set/?
Kurabiye adlı ayarlama 'test' ve ' . değeri ^strong>1'?
Ve özellikle, nasıl atanır?
CEVAP
Bakın eklentisi:
https://github.com/carhartl/jquery-cookie
Sonra da yapabilirsiniz:
$.cookie("test", 1);
Silmek için:
$.removeCookie("test");
Ayrıca, cookie on gün belirli bir sayıda (10) bir zaman aşımı süresi ayarlamak için:
$.cookie("test", 1, { expires : 10 });
Eğer bu seçenek atlanmış dolarsa, o zaman çerezi oturum çerezi olur, ve tarayıcıdan çıktığında silinir.
Tüm seçenekleri karşılamak için:
$.cookie("test", 1, {
expires : 10, //expires in 10 days
path : '/', //The value of the path attribute of the cookie
//(default: path of page that created the cookie).
domain : 'jquery.com', //The value of the domain attribute of the cookie
//(default: domain of page that created the cookie).
secure : true //If set to true the secure attribute of the cookie
//will be set and the cookie transmission will
//require a secure protocol (defaults to false).
});
Çerez değerini okumak geri:
var cookieValue = $.cookie("test");
Eğer çerez mevcut olan farklı bir yol üzerinde oluşturulursa, path parametresi belirlemek isteyebilirsiniz:
var cookieValue = $.cookie("test", { path: '/foo' });
GÜNCELLEME (Nisan 2015):
Belirtildiği gibi aşağıya yorum, takım üzerinde çalışan orijinal eklenti vardır çıkarılmış bir WordPress kullanmak bağımlılık yeni bir proje (https://github.com/js-cookie/js-cookie) aynı işlevselliği ve genel sözdizimi olarak jquery sürümü. Görünüşe göre orijinal eklenti olsa bir yere gitmiyor.
Nasıl son tamamlama Geri Al mı?...
Nasıl bir yönlendirme sayfası jQuery k...
Nasıl düğme jQuery ile seçili olan bil...
Nasıl jQuery ile sayfa yenileme yapabi...
En iyi şekilde'jQuery nin ev sahi...