ASP Cookies စုစည်းမှု
❮ ပြီးပြည့်စုံသော တုံ့ပြန်မှု Object ရည်ညွှန်းချက်
Cookies စုစည်းမှုကို ကွက်ကီးတန်ဖိုးများ သတ်မှတ်ရန် သို့မဟုတ် ရယူရန် အသုံးပြုပါသည်။ cookie မရှိပါက၊ ၎င်းကိုဖန်တီးမည်ဖြစ်ပြီး သတ်မှတ်ထားသောတန်ဖိုးကိုယူပါ။
မှတ်ချက်- Response.Cookies command သည် <html> tag ရှေ့တွင် ပေါ်လာရပါမည်။
အထားအသို
Response.Cookies(name)[(key)|.attribute]=value
variablename=Request.Cookies(name)[(key)|.attribute]
Parameter | Description |
---|---|
name | Required. The name of the cookie |
value | Required for the Response.Cookies command. The value of the cookie |
attribute | Optional. Specifies information about the cookie. Can be one of the following parameters:
|
key | Optional. Specifies the key to where the value is assigned |
ဥပမာများ
"Response.Cookies" အမိန့်ကို ကွက်ကီးဖန်တီးရန် သို့မဟုတ် ကွက်ကီးတန်ဖိုး သတ်မှတ်ရန် အသုံးပြုသည်-
<%
Response.Cookies("firstname")="Alex"
%>
အထက်ဖော်ပြပါ ကုဒ်တွင် ကျွန်ုပ်တို့သည် "firstname" ဟု အမည်ပေးထားသော ကွတ်ကီးတစ်ခုကို ဖန်တီးပြီး တန်ဖိုး "Alex" ကို ၎င်းတွင် သတ်မှတ်ပေးထားပါသည်။
ကွတ်ကီးသက်တမ်းကုန်ဆုံးမည့်ရက်စွဲကို သတ်မှတ်ခြင်းကဲ့သို့ ကွတ်ကီးတစ်ခုသို့ ရည်ညွှန်းချက်အချို့ကို ပေးဆောင်ရန်လည်း ဖြစ်နိုင်သည်-
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("firstname").Expires=#May 10,2002#
%>
ယခု "firstname" ဟု အမည်ပေးထားသည့် ကွတ်ကီးသည် "Alex" ၏တန်ဖိုးရှိပြီး ၎င်းသည် အသုံးပြုသူ၏ကွန်ပျူတာမှ မေလ 10၊ 2002 တွင် သက်တမ်းကုန်ဆုံးမည်ဖြစ်သည်။
"Request.Cookies" ညွှန်ကြားချက်ကို cookie တန်ဖိုးတစ်ခုရရှိရန် အသုံးပြုပါသည်။
အောက်ဖော်ပြပါ ဥပမာတွင်၊ ကျွန်ုပ်တို့သည် cookie "firstname" ၏တန်ဖိုးကို ရယူပြီး စာမျက်နှာတစ်ခုပေါ်တွင် ပြသသည်-
<%
fname=Request.Cookies("firstname")
response.write("Firstname=" & fname)
%>
အထွက်-
Firstname=Alex
ကွက်ကီးတစ်ခုတွင် တန်ဖိုးများစွာ စုစည်းမှုလည်း ပါဝင်နိုင်သည်။ ကွတ်ကီးတွင် သော့များရှိသည်ဟု ကျွန်ုပ်တို့ပြောကြသည်။
အောက်ဖော်ပြပါ ဥပမာတွင်၊ ကျွန်ုပ်တို့သည် "အသုံးပြုသူ" ဟု အမည်ပေးထားသော ကွတ်ကီးစုဆောင်းမှုကို ဖန်တီးပါမည်။ "အသုံးပြုသူ" ကွက်ကီးတွင် အသုံးပြုသူတစ်ဦးနှင့်ပတ်သက်သည့် အချက်အလက်ပါရှိသော သော့များပါရှိသည်-
<%
Response.Cookies("user")("firstname")="John"
Response.Cookies("user")("lastname")="Smith"
Response.Cookies("user")("country")="Norway"
Response.Cookies("user")("age")="25"
%>
အောက်ပါကုဒ်သည် သင့်ဆာဗာမှ သုံးစွဲသူတစ်ဦးထံ ပေးပို့ထားသော ကွတ်ကီးများအားလုံးကို ဖတ်သည်။ ကုဒ်သည် ကွတ်ကီးတစ်ခုတွင် HasKeys ပိုင်ဆိုင်မှုရှိ သော့များ ရှိမရှိ စစ်ဆေးသည်ကို သတိပြုပါ။
<html>
<body>
<%
dim x,y
for each x in Request.Cookies
response.write("<p>")
if Request.Cookies(x).HasKeys then
for each y in Request.Cookies(x)
response.write(x & ":" & y & "=" & Request.Cookies(x)(y))
response.write("<br>")
next
else
Response.Write(x & "=" & Request.Cookies(x) & "<br>")
end if
response.write "</p>"
next
%>
</body>
</html>
%>
အထွက်-
firstname=Alex
user:firstname=John
user:lastname=Smith
user:
country=Norway
user:
age=25
❮ ပြီးပြည့်စုံသော တုံ့ပြန်မှု Object ရည်ညွှန်းချက်