Cookies expires very soon

Dear All,
I have develped cookies based admin tool this way:
login page wil have this code, after successful log in, cookies wil be written and expired after 1 hr.

strName = objRs("AdminName")
strLogin = objRs("AdminLogin")
intID = objRs("ID")
Response.Cookies("Admin")("name") = strName
Response.Cookies("Admin")("login") = strLogin
Response.Cookies("Admin")("id") = intID
Response.Cookies("Admin").Expires = dateadd("H",1,now)
Response.Redirect("admin.asp")

in admin page first we wil check for saved cookies. code is something like :

Dim adminName, adminId, adminLogin, adminArea

adminName = Request.Cookies("Admin")("name")
adminLogin = Request.Cookies("Admin")("login")
adminId = Request.Cookies("Admin")("id")
adminArea = Request.Cookies("Admin")("area")


IF adminName = "" OR adminLogin = "" OR adminId = "" THEN
Response.Redirect "login.asp"
End IF


now the problem is my cookies are getting expired within 5 min. and i redirecting to login page
how i can fix now ?
aspbankAsked:
Who is Participating?
 
kevp75Commented:
yes, you would need to do the 3 cookies seperatly.

try the cookies folder.  windowsXP and 2000

c:\documents and setting\username\cookies

windows ME and down:(if I remember correctly)

c:\windows\cookies
0
 
smaccariCommented:
There is maybe a possible issue in a difference between datetime on your server and on the clientside.
I think that cookies expires following the client date time, not server.
So, if you create a cookie with expiration now + 1 hour, server date, and that the client is on a time zone with 1 hour more, your cookie will expires as it is created.
0
 
aspbankAuthor Commented:
thanks for your reply,
i removed that line and tried but the same problem
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
smaccariCommented:
Can you try to add a Response.Buffer = True like this:

Response.Buffer = True

...'your code

strName = objRs("AdminName")
strLogin = objRs("AdminLogin")
intID = objRs("ID")
Response.Cookies("Admin")("name") = strName
Response.Cookies("Admin")("login") = strLogin
Response.Cookies("Admin")("id") = intID
Response.Cookies("Admin").Expires = dateadd("H",1,now)
Response.Redirect("admin.asp")
Response.End
0
 
kevp75Commented:
i'v had an issue like this as well.  and I found that the problem lies with how the cookies are structured.

You have (and I had)  response.cookies("Admin")("name")

i found that using .Expires on the ("Admin") does not work.  What I had to do, was get rid of it.  So I did

response.cookies("Admin_name") = strName
response.cookies("Admin_name").Expires - dateadd("H",1,Now())

and it worked
0
 
aspbankAuthor Commented:
and how about other keys ?
do i need to create 3 cookies seperately ?

response.cookies("Admin_name") = strName
response.cookies("Admin_name").Expires - dateadd("H",1,Now())

response.cookies("Admin_login") = strName
response.cookies("Admin_login").Expires - dateadd("H",1,Now())

response.cookies("Admin_id") = strName
response.cookies("Admin_id").Expires - dateadd("H",1,Now())


this way ?
0
 
aspbankAuthor Commented:
and second thing is i opened temporary intenet folder, there i did not find any file for this cookies. why it is so ?


0
 
kevp75Commented:
I'm a little confused.  Why the C grade?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.