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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
aspbankAuthor Commented:
thanks for your reply,
i removed that line and tried but the same problem
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
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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
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 ?
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 ?


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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevp75Commented:
I'm a little confused.  Why the C grade?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.