Forums
This topic is locked
Cookies expire when browser closes
Posted 29 Jun 2002 07:30:19
1
has voted
29 Jun 2002 07:30:19 aegis kleais posted:
Using the code:Response.Cookies("username" = john
to set a cookie and
Request.Cookies("username"
to retrieve a cookie
I found that everything works fine with my login system. However, when you close your browser out, the cookies are flushed. Just like a session! I thought the server wrote the cookie to the browser for retrieval later on (even if the user closes the browser)
Is there a way to keep cookies on a user's system? I know that no domain can place over 4kb of cookies but all I use are a username and password for cookies; I don't go overboard with em.....
Replies
Replied 30 Jun 2002 18:12:31
30 Jun 2002 18:12:31 Dave Clarke replied:
Don't know much about cookies but it sounds to me as though you have cookies set to accept only session cookies in your browser.
In IE6 you can have cookies set to accept cookies that are written to your system for later retrieval or to only accept session cookies.
Dave
In IE6 you can have cookies set to accept cookies that are written to your system for later retrieval or to only accept session cookies.
Dave
Replied 01 Jul 2002 07:37:12
01 Jul 2002 07:37:12 aegis kleais replied:
No...that wasn't it....I turned on ALLOW SESSION COOKIES (was off) and it's still not working.....lemme get in depth as to how I did this.
Ok, on LOGIN.ASP page I have a USERNAME textfield and PASSWORD textfield
USERNAME's value is set to <%= Request.Cookies("uname" %>
PASSWORD's value is set to <%= Request.Cookies("pword" %>
Then I use the UD Server Behavior to make the form a LOGIN form. In the page's code, I locate the ASP line that detects a successful user, and before it uses RESPONSE.REDIRECT to goto the specified page, I enter the following ASP:
Session("username" = Session("MM_Username"
(since the Login Behavior uses a form that uses POST.)
This is successful cause on the page the successful login goes to (INDEX.ASP) I have an area with the code:
<%= Session("username" %>
and sure enough, the logged in user is displayed. So anyways, on the INDEX.ASP page, I have a recordset that is created from the Session("MM_Username" that does the following:
Response.Cookies("uname" = (rcdLoggedInUser.Fields.Item("fldUsername".Value)
Response.Cookies("pword" = (rcdLoggedInUser.Fields.Item("fldPassword".Value)
So basically, I assume that if cookies are set on the browser, you can close the browser down and come back later and they should still work. So I tested this:
I didn't close the browser, but I just went back to the login page, and sure enough, the username field now had the username in it and the password had the password in it.
But I closed the browser, reopened and went back to the page and the field were empty <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Does ASP have a permanent method of Cookie storage?
Ok, on LOGIN.ASP page I have a USERNAME textfield and PASSWORD textfield
USERNAME's value is set to <%= Request.Cookies("uname" %>
PASSWORD's value is set to <%= Request.Cookies("pword" %>
Then I use the UD Server Behavior to make the form a LOGIN form. In the page's code, I locate the ASP line that detects a successful user, and before it uses RESPONSE.REDIRECT to goto the specified page, I enter the following ASP:
Session("username" = Session("MM_Username"
(since the Login Behavior uses a form that uses POST.)
This is successful cause on the page the successful login goes to (INDEX.ASP) I have an area with the code:
<%= Session("username" %>
and sure enough, the logged in user is displayed. So anyways, on the INDEX.ASP page, I have a recordset that is created from the Session("MM_Username" that does the following:
Response.Cookies("uname" = (rcdLoggedInUser.Fields.Item("fldUsername".Value)
Response.Cookies("pword" = (rcdLoggedInUser.Fields.Item("fldPassword".Value)
So basically, I assume that if cookies are set on the browser, you can close the browser down and come back later and they should still work. So I tested this:
I didn't close the browser, but I just went back to the login page, and sure enough, the username field now had the username in it and the password had the password in it.
But I closed the browser, reopened and went back to the page and the field were empty <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Does ASP have a permanent method of Cookie storage?
Replied 01 Jul 2002 11:26:42
01 Jul 2002 11:26:42 Dave Clarke replied:
hi
try the "remember me" extension here
www.basic-ultradev.com/extensions/downloads.asp?id=47
this works and maybe you can disect it.
Dave
Edited by - Davecl on 01 Jul 2002 11:27:17
try the "remember me" extension here
www.basic-ultradev.com/extensions/downloads.asp?id=47
this works and maybe you can disect it.
Dave
Edited by - Davecl on 01 Jul 2002 11:27:17
Replied 01 Jul 2002 18:59:59
01 Jul 2002 18:59:59 aegis kleais replied:
Thanks, but it still doesn't work
If you don't place an expiration in there it places the following code
Response.Cookies("username".expires = Date +
Which causes a syntax error.
But once I removed the expiration (cause I don't want them to expire), I ran it again and it kept my cookies til the browser was closed out again.....
I guess I'm going to have to find a javascript solution. I'm just VERY suprised ASP couldn't do such a simple thing as placing a cookie and reading one!
If you don't place an expiration in there it places the following code
Response.Cookies("username".expires = Date +
Which causes a syntax error.
But once I removed the expiration (cause I don't want them to expire), I ran it again and it kept my cookies til the browser was closed out again.....
I guess I'm going to have to find a javascript solution. I'm just VERY suprised ASP couldn't do such a simple thing as placing a cookie and reading one!
Replied 01 Jul 2002 20:55:45
01 Jul 2002 20:55:45 Dave Clarke replied:
I know what you mean about the expiration date but couldn't you set the expiration to a ridiculously high number, so that it doesnt expire?
I have mine set to 10000 days and it seems to run ok.
I still think the cookies fluhing when you close the browser could be a settings problem, have you looked in TEMPORARY INTERNET FILES to see if they are being written? or wherever it is that you have cookies saving to?
Dave
I have mine set to 10000 days and it seems to run ok.
I still think the cookies fluhing when you close the browser could be a settings problem, have you looked in TEMPORARY INTERNET FILES to see if they are being written? or wherever it is that you have cookies saving to?
Dave
Replied 01 Jul 2002 22:40:14
01 Jul 2002 22:40:14 aegis kleais replied:
I'll give the "set to a high value attempt" I did see the area in IE6 that ask to ALLOW SESSION COOKIES. I tried it with that both on and off and no go. Hopefully if I set this expiration super high, it'll keep it in the cookies. I can go look at the cookies file and see what's been set or not. Good ideas; i'll let you know how they end up. Thx!
Replied 02 Jul 2002 01:24:02
02 Jul 2002 01:24:02 Dave Clarke replied:
another thought, in internet options in IE, under the privacy tab, there is a slider for cookie acceptance, try lowering it.
Dave
Edited by - Davecl on 02 Jul 2002 01:28:46
Dave
Edited by - Davecl on 02 Jul 2002 01:28:46
Replied 02 Jul 2002 02:51:18
02 Jul 2002 02:51:18 aegis kleais replied:
Well, I found the cookies file and it is indeed wiritng the cookie....For somereason, it's not reading the cookie info after the browser's been closed and reopened....
Replied 02 Jul 2002 11:32:25
02 Jul 2002 11:32:25 Dave Clarke replied:
sorry
i'm stumped
Dave
i'm stumped
Dave
Replied 02 Jul 2002 13:51:14
02 Jul 2002 13:51:14 Owen Eastwick replied:
Try:
<%
Response.Cookies("MyDomainName"("Username" = varUsername
Response.Cookies("MyDomainName" = Date + 30
%>
AND
<%
varUsername = Request.Cookies("MyDomainName"("Username"
%>
You don't have to use your domian name, but you need to have a named container container into which the cookie value username is placed.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
<%
Response.Cookies("MyDomainName"("Username" = varUsername
Response.Cookies("MyDomainName" = Date + 30
%>
AND
<%
varUsername = Request.Cookies("MyDomainName"("Username"
%>
You don't have to use your domian name, but you need to have a named container container into which the cookie value username is placed.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 02 Jul 2002 19:19:37
02 Jul 2002 19:19:37 aegis kleais replied:
I changed your line that read:
Response.Cookies("MyDomainName" = Date + 30
To
Response.Cookies("MyDomainName".expires = Date + 30
And it works! So does this mean that anytime I set a cookie I have to set it's expiration, or it just becomes a session cookie?
Response.Cookies("MyDomainName" = Date + 30
To
Response.Cookies("MyDomainName".expires = Date + 30
And it works! So does this mean that anytime I set a cookie I have to set it's expiration, or it just becomes a session cookie?
Replied 02 Jul 2002 23:02:53
02 Jul 2002 23:02:53 Owen Eastwick replied:
Ooops, sorry, that was missed off by mistake.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo