How to expire cookie when closing window - Posted (2583 Views)
Starting Member
gent
Posts: 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<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Retired Admin
gor
Posts: 5511
5511
Try this:

in inc_top.asp change this code starting around line 61:

select case Request.Form("Method_Type")

case "login"
select case ChkUser2(Request.Form("Name"), Request.Form("Password"))
case 1, 2, 3, 4
Call DoCookies(Request.Form("SavePassword")) strLoginStatus = 1
case else
strLoginStatus = 0
end select
case "logout"
Call ClearCookies()

end select

further down starting around line 193:

<%	if (strAuthType = "db") then %>
<td><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">Username:</font>
<INPUT type="text" name="Name" size="10" value=""></td>
<td><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">Password:</font>
<INPUT type="password" name="Password" size="10" value=""></td>
<td valign="bottom">
<% if strGfxButtons <> "0" then %>
<INPUT src=button_login.gif type="image" value="Login" id=submit1 name=submit1 border=0 hspace=4>
<% else %>
<% if strGfxButtons = "0" then %>
<INPUT type="submit" value="Login" id=submit1 name=submit1>
<% end if %>
<% end if %>
</td>
<tr>
<td colspan="3" align="left"><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">
<INPUT type="checkbox" name="SavePassWord" value="true"> Save my Password</font>
</td>
<% else %>

in inc_functions.asp change the DoCookies() function to:

sub DoCookies(fSavePassWord)
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")
if fSavePassWord = "true" then
Response.Cookies(strCookieURL & "User").Expires = dateAdd("d", 30, strForumTimeAdjust)
end if
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

in register.asp change line 268 to:

Call DoCookies("")
(this needs to be done or else you get an error when registering a new user)

Remember I didn't have time to check and re-check all the code, but the first few tests at my server worked: Only if you select the "save my password" checkbox before loggin on the username and password are saved after you close the browser.
Pierre Gorissen
Even if you're on the right track,
you'll get run over if you just sit there.
Will Rogers<
Posted
New Member
Huntress
Posts: 96
96
You know this is done in an easier way by not allowing the save password function as follows, in inc_header.asp find this:

Code:

" <input type=""checkbox"" name=""SavePassWord"" value=""true"" tabindex=""-1"" CHECKED><b>Save Login </b>" & _

And change it to:

Code:

" <input type=""hidden"" name=""SavePassWord"" value=""false"" tabindex=""-1"">" & _

This removes the Save Password checkbox, and never saves the password to the cookie, thus they are not logged in when the browser is closed.
<
There are 10 kinds of people, those that understand binary, and those that don't.
Posted
General Help Moderator
Gremlin
Posts: 7528
7528
Did you notice the age of the thread ? hehe 2 years old was probably talking about version 3.1 or earlier back then.<
Kiwihosting.Net - The Forum Hosting Specialists
Posted
New Member
Huntress
Posts: 96
96
LOL that's funny... I was researching something else and stubled across this and didn't notice the year... I thought it was only a few weeks old... jeez I'm embarrassed now. LOL

My new motto, I'm here to help, you just have to wait 2 years bigsmile<
There are 10 kinds of people, those that understand binary, and those that don't.
Posted
General Help Moderator
Gremlin
Posts: 7528
7528
ROFL :) Love the motto Huntress !<
Kiwihosting.Net - The Forum Hosting Specialists
Posted
Access 2000 Support Moderator
davemaxwell
Posts: 3020
3020
I officially nominate Huntress to be the "old bug" fixer! bigsmile<
Dave Maxwell
Barbershop Harmony Freak
Posted
New Member
Huntress
Posts: 96
96
Thanks Dave I'm so honored! bigsmile
The one good thing about this is the lack of pressure LOL<
There are 10 kinds of people, those that understand binary, and those that don't.
You Must enter a message