[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cookies expires very soon

Posted on 2006-04-04
10
Medium Priority
?
1,929 Views
Last Modified: 2012-08-13
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 ?
0
Comment
Question by:aspbank
  • 3
  • 3
  • 2
8 Comments
 
LVL 9

Expert Comment

by:smaccari
ID: 16379167
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
 

Author Comment

by:aspbank
ID: 16380954
thanks for your reply,
i removed that line and tried but the same problem
0
 
LVL 9

Expert Comment

by:smaccari
ID: 16381154
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Expert Comment

by:kevp75
ID: 16382465
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
 

Author Comment

by:aspbank
ID: 16383140
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
 

Author Comment

by:aspbank
ID: 16383160
and second thing is i opened temporary intenet folder, there i did not find any file for this cookies. why it is so ?


0
 
LVL 25

Accepted Solution

by:
kevp75 earned 750 total points
ID: 16383387
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
 
LVL 25

Expert Comment

by:kevp75
ID: 16417806
I'm a little confused.  Why the C grade?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question