How to expire cookie when closing window - نوشته شده در (2588 Views)
Starting Member
gent
مطلب: 5
5
I have the problem of the forum keeping the cookie alive when closing the window. I am automatically looged in when I start. I do not want this, since people will be logging on via public computers. Can I fix it?
/ Gent


/ Gent<
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Development Team Member
Davio
مطلب: 12217
12217
Well, 2 sure ways I can think of is, press the Logout button at the top before leaving the forum. You won't auto login the next time someone visits from the same computer.
Or you can manually delete the cookie from your computer that was created if you didn't logout of the forum.
*----*----*----*----*----*----*----*----*----*----*----*
"However, if you suffer as a Christian, do not be ashamed,
but praise God that you bear that name."
1 Peter 4:16
<
نوشته شده در
Starting Member
gent
مطلب: 5
5
Thanks, but this is not a very secure way. People will forget this from time to time. Is there not a way to limit the cookie's existence to the browser window? Also maybe a time-limit as well?
/ Gent

Edited by - gent on 06 November 2000 00:56:46<
نوشته شده در
Starting Member
jwilliams
مطلب: 18
18
jeeez... can't someone give these guys a good answer?
i am not an ASP developer (im really a Java dude), but I think you can use a global.asa file with a Session_OnStart method and use an ASP session instead of a cookie and then tell IIS to shorten the timeout of the session in your web server properties... errr whatever... this is actually pretty easy to do.
<
نوشته شده در
Retired Admin
gor
مطلب: 5511
5511
Hey dude,

Could you please start reading your posts over once more before posting them ? The last few minutes I've been reading nothing but negative posts by you.
Because jeeeez... your answer wasn't that great either, because the easiest way to have a cookie expire when the browser closes is by just not setting the expiration date.
Please understand that all people posting here are trying to help other members. If you like to do that also, and are willing to do that in a polite way: please do so, we are happy with all the help we get smile If not, please stay away.
Pierre Gorissen
Even if you're on the right track,
you'll get run over if you just sit there.
Will Rogers<
نوشته شده در
Support Moderator
Doug G
مطلب: 6493
6493
Relax, already smile
======
Doug G
======<
نوشته شده در
Starting Member
gent
مطلب: 5
5
Can you please tell me how to do this?
Kind Regards,

/ Gent

... because the easiest way to have a cookie expire when the browser closes is by just not setting the expiration date.


/ Gent<
نوشته شده در
Retired Admin
gor
مطلب: 5511
5511
Ok, I'm not sure it fixes it for the forums all at once, but it should get you an idea of what to look for:

in inc_functions.asp you find this:

sub DoCookies()
if strSetCookieToForum = 1 then
Response.Cookies(strCookieURL & "User").Path = strCookieURL
else
Response.Cookies(strCookieURL & "User").Path = "/"
end if
Response.Cookies(strCookieURL & "User")("Name") = Request.Form("Name")
Response.Cookies(strCookieURL & "User")("Pword") = Request.Form("Password")
Response.Cookies(strCookieURL & "User")("Cookies") = Request.Form("Cookies")
Response.Cookies(strCookieURL & "User").Expires = dateAdd("d", 30, strForumTimeAdjust) Session(strCookieURL & "last_here_date") = ReadLastHereDate(Request.Form("Name"))
if strAuthType = "nt" then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(Session(strCookieURL & "userID"))
end if
end sub

Now there are some more places in the code where cookies are set, if you want to find those just do a search for .Expires and you should be able to find them. I'm not sure what happens if there allready is a cookie there with .Expires set to something so you might need to have to delete your cookie(s) first.
If it works, please report back here because it would be nice to add this as a user-selectable option. (like you see at hotmail i.e.)

Pierre Gorissen
Even if you're on the right track,
you'll get run over if you just sit there.
Will Rogers<
نوشته شده در
Starting Member
Ken
مطلب: 3
3
I added ' in front of the .expire line and it works fine on my forums. How do I go about adding this as a feature for the user to select?
quote:
Ok, I'm not sure it fixes it for the forums all at once, but it should get you an idea of what to look for:

in inc_functions.asp you find this:

sub DoCookies()
if strSetCookieToForum = 1 then
Response.Cookies(strCookieURL & "User").Path = strCookieURL
else
Response.Cookies(strCookieURL & "User").Path = "/"
end if
Response.Cookies(strCookieURL & "User")("Name") = Request.Form("Name")
Response.Cookies(strCookieURL & "User")("Pword") = Request.Form("Password")
Response.Cookies(strCookieURL & "User")("Cookies") = Request.Form("Cookies")
Response.Cookies(strCookieURL & "User").Expires = dateAdd("d", 30, strForumTimeAdjust) Session(strCookieURL & "last_here_date") = ReadLastHereDate(Request.Form("Name"))
if strAuthType = "nt" then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(Session(strCookieURL & "userID"))
end if
end sub

Now there are some more places in the code where cookies are set, if you want to find those just do a search for .Expires and you should be able to find them. I'm not sure what happens if there allready is a cookie there with .Expires set to something so you might need to have to delete your cookie(s) first.
If it works, please report back here because it would be nice to add this as a user-selectable option. (like you see at hotmail i.e.)

Pierre Gorissen
Even if you're on the right track,
you'll get run over if you just sit there.
Will Rogers

<
نوشته شده در
Retired Admin
gor
مطلب: 5511
5511
Ehm, haven't thought about it very long yet, I think that the quickest way to do it is to add a checkbox in inc_top.asp so that it displays dissapprove Save password and then use this value to do something like

if checkbox = true then
Response.Cookies(strCookieURL & "User").Expires = dateAdd("d", 30, strForumTimeAdjust)
end if

so that the expires property only gets set if the checkbox is checked.


Pierre Gorissen
Even if you're on the right track,
you'll get run over if you just sit there.
Will Rogers<
نوشته شده در
Starting Member
Ken
مطلب: 3
3
Not sure if I did this correctly but I add this to the inc_top.asp and it does not save the cookie.
<input type="checkbox" name="savepassword" value="">
Save Password
<%
if checkbox = true then
Response.Cookies(strCookieURL & "User").Expires = dateAdd("d", 30, strForumTimeAdjust)
end if
%>

Any sugestions?
<
شما باید یک متن وارد کنید