Andrew Asher
|
Posted: 05/25/2003, 3:46 PM |
|
I am trying to add a check box to the login form that gives a registered
user the option of remembering their login details for this machine. I
don't want this to be a permanent option but on a per machine basis so users
at public machines don't get their passwords remembered at the internet cafe
in the Zambezi!
So I guess I need to check if remember checkbox value = checked, then login
details are recorded in cookie. Also the login form needs to retrieve login
details from the cookie if checkbox value - checked or else as usual use the
values in the posted form. Also what happens if the user changes their
password - when does the login cookie get re-writen? I guess the checkbox
value would be stored in the cookie as well?
Any ideas or plans of attack to this would be greatly welcomed.
Andrew Asher
Auckland, New Zealand
|
|
|
DonB
|
Posted: 05/25/2003, 6:59 PM |
|
Try the following. There is a "Onclick" on the Login button, to which I
added another block of cEvent ustom code. Then I added two other blocks of
Event custom code - to the BeforeShow and BeforeUnload of the login page. I
also added a checkbox named "RememberMe" to the login form
DonB
Function Login_Button_DoLogin_OnClick() 'Login_Button_DoLogin_OnClick
@3-ADB4691A
'Login @4-AA430BB1
With Login
If NOT CCLoginUser(.login.Value, .password.Value) Then
.Errors.addError("Login or Password is incorrect.")
Login_Button_DoLogin_OnClick = False
.password.Value = ""
Else
If Not IsEmpty(CCGetParam("ret_link", Empty)) Then _
Redirect = CCGetParam("ret_link", Empty)
Login_Button_DoLogin_OnClick = True
End If
End With
'End Login
'============== The above lines are the standard "login Onclick" CCS built
for me ================='
'Custom Code @14-73254650
' -------------------------
' On successful login, persist cookies by giving them an Expires value
If Login.password.Value <> "" And Login.RememberMe.Value Then
Response.Cookies("login").Expires = now + 1
Response.Cookies("pass").Expires = now + 1
End If
' -------------------------
'End Custom Code
End Function 'Close Login_Button_DoLogin_OnClick @3-54C34B28
Function Page_BeforeShow() 'Page_BeforeShow @1-653D685B
'Custom Code @10-73254650
' -------------------------
' Retrieve login info from cookies
Login.login.Value = Request.Cookies("login")
Login.password.Value = Request.Cookies("pass")
' -------------------------
'End Custom Code
End Function 'Close Page_BeforeShow @1-54C34B28
Function Page_BeforeUnload() 'Page_BeforeUnload @1-A9F5B785
'Custom Code @12-73254650
' -------------------------
' Save login info in cookies
Response.Cookies("login") = Login.login.Value
Response.Cookies("pass") = Login.password.Value
' -------------------------
'End Custom Code
End Function 'Close Page_BeforeUnload @1-54C34B28
"Andrew Asher" <Andrew.Asher@clear.net.nz> wrote in message
news:barh3c$688$1@news.codecharge.com...
> I am trying to add a check box to the login form that gives a registered
> user the option of remembering their login details for this machine. I
> don't want this to be a permanent option but on a per machine basis so
users
> at public machines don't get their passwords remembered at the internet
cafe
> in the Zambezi!
>
> So I guess I need to check if remember checkbox value = checked, then
login
> details are recorded in cookie. Also the login form needs to retrieve
login
> details from the cookie if checkbox value - checked or else as usual use
the
> values in the posted form. Also what happens if the user changes their
> password - when does the login cookie get re-writen? I guess the checkbox
> value would be stored in the cookie as well?
>
> Any ideas or plans of attack to this would be greatly welcomed.
>
> Andrew Asher
> Auckland, New Zealand
>
>
>
>
|
|
|
Andrew Asher
|
Posted: 05/26/2003, 10:06 PM |
|
Thanks for this Don,
Ive probably ballsed something up as Im only getting a temp cookie created -
it works untill you close the browser ( Ive checked the cookie directory and
its there untill you close the browser). The password is remembered for the
current session as well ( If you go back to the login page the details are
correctly inserted.
In the code youve supplied should the "RememberMe.Value" have a value?
Should this = the value if that check box is clicked?
Thanks again
Andrew
"DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
news:barse2$tke$1@news.codecharge.com...
> Try the following. There is a "Onclick" on the Login button, to which I
> added another block of cEvent ustom code. Then I added two other blocks
of
> Event custom code - to the BeforeShow and BeforeUnload of the login page.
I
> also added a checkbox named "RememberMe" to the login form
>
>
> DonB
>
>
> Function Login_Button_DoLogin_OnClick() 'Login_Button_DoLogin_OnClick
> @3-ADB4691A
>
> 'Login @4-AA430BB1
> With Login
> If NOT CCLoginUser(.login.Value, .password.Value) Then
> .Errors.addError("Login or Password is incorrect.")
> Login_Button_DoLogin_OnClick = False
> .password.Value = ""
> Else
> If Not IsEmpty(CCGetParam("ret_link", Empty)) Then _
> Redirect = CCGetParam("ret_link", Empty)
> Login_Button_DoLogin_OnClick = True
> End If
> End With
> 'End Login
> '============== The above lines are the standard "login Onclick" CCS built
> for me ================='
>
> 'Custom Code @14-73254650
> ' -------------------------
> ' On successful login, persist cookies by giving them an Expires value
>
> If Login.password.Value <> "" And Login.RememberMe.Value Then
>
> Response.Cookies("login").Expires = now + 1
> Response.Cookies("pass").Expires = now + 1
>
> End If
>
> ' -------------------------
> 'End Custom Code
>
> End Function 'Close Login_Button_DoLogin_OnClick @3-54C34B28
>
>
>
> Function Page_BeforeShow() 'Page_BeforeShow @1-653D685B
>
> 'Custom Code @10-73254650
> ' -------------------------
>
> ' Retrieve login info from cookies
>
> Login.login.Value = Request.Cookies("login")
> Login.password.Value = Request.Cookies("pass")
>
> ' -------------------------
> 'End Custom Code
>
> End Function 'Close Page_BeforeShow @1-54C34B28
>
>
>
> Function Page_BeforeUnload() 'Page_BeforeUnload @1-A9F5B785
>
> 'Custom Code @12-73254650
> ' -------------------------
>
> ' Save login info in cookies
>
> Response.Cookies("login") = Login.login.Value
> Response.Cookies("pass") = Login.password.Value
>
> ' -------------------------
> 'End Custom Code
>
> End Function 'Close Page_BeforeUnload @1-54C34B28
>
>
> "Andrew Asher" <Andrew.Asher@clear.net.nz> wrote in message
>news:barh3c$688$1@news.codecharge.com...
> > I am trying to add a check box to the login form that gives a registered
> > user the option of remembering their login details for this machine. I
> > don't want this to be a permanent option but on a per machine basis so
> users
> > at public machines don't get their passwords remembered at the internet
> cafe
> > in the Zambezi!
> >
> > So I guess I need to check if remember checkbox value = checked, then
> login
> > details are recorded in cookie. Also the login form needs to retrieve
> login
> > details from the cookie if checkbox value - checked or else as usual use
> the
> > values in the posted form. Also what happens if the user changes their
> > password - when does the login cookie get re-writen? I guess the
checkbox
> > value would be stored in the cookie as well?
> >
> > Any ideas or plans of attack to this would be greatly welcomed.
> >
> > Andrew Asher
> > Auckland, New Zealand
> >
> >
> >
> >
>
>
|
|
|
DonB
|
Posted: 05/27/2003, 5:37 AM |
|
RememberMe.Value is a boolean so no "=" in the If-Then.
Cookies are temporary if there is no exipiration assigned to them. In my
example, I set it to one day, which actually is not very helpful to you.
Try setting it to something like "01/01/2030". Without setting .Expires
into the future, the cookie expires when the session ends.
DonB
|
|
|
|