|
-
Apr 3rd, 2001, 04:25 AM
#1
Thread Starter
Fanatic Member
Hi i wish to ask visitors to my page their age and stor it as a cookie for further viists my code goes like this
if document.cookie = " "
then vname =INPUTBOX("Please enter name")
Document.Write "Hello" & " " & vname & " " & "and"
cookie1= vname & ";expires=Wed, 07 Nov 2001 12:00:00 GMT"
Document.Cookie = cookie1
else
cookie2= document.cookie
document.write "Welcom back" & cookie2
end if
Can any one tell me what i am doing wrong, apart from pretending i am a programmer!!!!
Thanks
Useful Links
.Net
#Develop, GhostDoc, CodeKeep , be.PINVOKE, Good Code Snippet Site
Krypton Toolkit, XPCC / XP Common Controls, QSS Windows Forms Components
VB.COM
VB.Classic Help File, MB Controls, MZTools, ADO Stored Procedure Generator add-in,
-
Apr 3rd, 2001, 05:20 PM
#2
Frenzied Member
Looks to me like your trying to write a cookie from the client side code. Cookies are written to the client in the HTTP headers *before* a page is displayed. You have to submit your age value to a page (can even be the same page) that then writes the cookies BEFORE the HTML tag.
Then the syntax is
Code:
'Write the cookie
Response.Cookies("UserAge") = Request.Form("txtAge")
Response.Cookies("UserAge").Expires = Date + 15
and
Code:
'Read the cookie
Dim intAge
For each Item in Request.Cookies
'You can also include any other cookies you have here to be read
If Item="UserAge" Then
intAge = CInt(Request.Cookies(Item))
End If
Next
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Apr 5th, 2001, 06:12 AM
#3
Thread Starter
Fanatic Member
HI I got my cookies to work, and by going along th road i started going down
view code:
dim cookier, cookiew, uname
cookier=document.cookie
mess= "Welcome back " & cookier
if Len(mess)> 14 then
else
uname =INPUTBOX("Please enter name")
mess = "hello"&" " & uname & " and"
cookiew= uname & ";expires=Wed, 07 Nov 2001 12:00:00 GMT"
Document.Cookie = cookiew
End if
document.write mess
Try it out atsrburrows.20m.com
Useful Links
.Net
#Develop, GhostDoc, CodeKeep , be.PINVOKE, Good Code Snippet Site
Krypton Toolkit, XPCC / XP Common Controls, QSS Windows Forms Components
VB.COM
VB.Classic Help File, MB Controls, MZTools, ADO Stored Procedure Generator add-in,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|