HttpCookieCollection.Add(HttpCookie) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menambahkan cookie yang ditentukan ke koleksi cookie.
public:
void Add(System::Web::HttpCookie ^ cookie);
public void Add(System.Web.HttpCookie cookie);
member this.Add : System.Web.HttpCookie -> unit
Public Sub Add (cookie As HttpCookie)
Parameter
- cookie
- HttpCookie
untuk HttpCookie ditambahkan ke koleksi.
Contoh
Contoh berikut membuat koleksi cookie baru dan cookie baru bernama "LastVisit", menetapkan nilai cookie ke tanggal dan waktu saat ini, dan menambahkan cookie ke koleksi baru.
HttpCookieCollection MyCookieCollection = new HttpCookieCollection();
HttpCookie MyCookie = new HttpCookie("LastVisit");
MyCookie.Value = DateTime.Now.ToString();
MyCookieCollection.Add(MyCookie);
Dim MyCookieCollection as New HttpCookieCollection()
Dim MyCookie As New HttpCookie("LastVisit")
MyCookie.Value = DateTime.Now().ToString()
MyCookieCollection.Add(MyCookie)
Keterangan
Sejumlah koleksi cookie dapat ada dalam aplikasi, tetapi hanya koleksi yang dirujuk oleh objek intrinsik Cookies yang dikirim ke klien.
Metode ini Add memungkinkan cookie duplikat dalam koleksi cookie. Set Gunakan metode untuk memastikan keunikan cookie dalam koleksi cookie.