close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Login page cookies

Thread began 6/07/2012 8:03 am by amucino12002 | Last modified 6/07/2012 12:32 pm by amucino12002 | 2444 views | 10 replies |

amucino12002

Login page cookies

I am trying to figure out the login.php page created with the wizard and since there are no instructions to do things manually i only have left to ask, sorry.

I noticed that when checkboxes are checked it stores cookies to either remember or even autologin.

I have tried to create the same in my login page with no success. Could you please provide instructions?

Thanks,

Sign in to reply to this post

Jason ByrnesWebAssist

for the remember me option:

create a checkbox named Remember Me, set the checked value to 1

Add a Set Cookie Value behavior (WebAssist -> Cookies -> Set Cookie with PHP)

For the trigger, click the lightning bolt icon and select the Remember me checkbox.

set the name to Remember

for the value click the lightning bolt icon and select the remember me checkbox.

Repeat those steps again, same trigger, but this time set the name to username and select the username form element

repeat again, same trigger, name = password, for the value select the password form element

now the the cookies are set, use them as the initial value of the form elements.

select the username text box, in the property inspector click the lightning bolt next to initial value, and select the username cookie

repeat for the password filed, using the password cookie.

for the username checkbox, click the dynamic button, and click the lightning bolt icon next to check if, select the remember cookie binding

set "Equal To" to 1

for auto login, create an auto login checkbox, set value to 1,

create a auto login cookie the same way the remember me cookie is set.

add an additional Security Assist Authenticate user behavior, it will be set up exactly the same as the original one, except for the trigger, click the lightning bolt icon and select the auto login cookie.

on the database tab, set the username and password columns to use the user and password cookie variables.

Sign in to reply to this post

amucino12002

I did but cookies dont work properly, it remembers username and password i check the box .. it remembers, i uncheck and log in, then log out the cookies are still there and username/password is remembered.
Also the checkbox is not remembered.

I am posting the page in the other thread for the spry, maybe some code is conflicting, but that should be it for this page. it all looks good other than cookies and spry.

Also, the autologin checkbox after i checked it and loged out, went back to the login page and nothing happened.

Sign in to reply to this post

Jason ByrnesWebAssist

well, to unset the cookies if the checkboxes are unhecked, you would need to add additioanl set cookie behaviors that set the values to be blank, then hand edit the trigger code so that it would occur if the submit button where pressed, and the checkboxes left blank, for example:

<?php
if ((isset($_POST["imageField_x"])&&(!isset($_POST["Rememberme"])) && $_POST["imageField_x"] != "")) {
setcookie("password", "", time()+(60*60*24*30), "/", "", 0);
}
?>


as for the checkboxes not remembering the state, you are using the wrong cookies in the dynamic checkbox settings.

in the dynamic checkbox setting for the remember me checkbox, you need to use the Remember cookie.

in the dynamic settings for the password checkbox, use the password cookie.



the auto login is not working because you are using the form element bindings, you need to use the cookie bindings on for the trigger and for the database tab.

Sign in to reply to this post

amucino12002

I got the cookies to work and the autologin as well. I ran into the obvious issue. When user selects 'autologin' on the log out page i need to add a "Forget me" link so that user can delete the cookies, in case someone else wants to log in.

Does Webassist has a behavior to clear the cookies created by it ?

As for the deleting cookies by unchecking the boxes i would need more detailed info, at this time i am learning both PHP and your extensions, i would appreciate it if you could help with those.

Almost there ... thx !

Sign in to reply to this post

Jason ByrnesWebAssist

to clear a cookie, you use the set cookie behavior and set the expiration date to a date in the past.


this code is an example of how to clear the password cookie if the remember me button is unchecked and the login form submited:

php:
<?php

if ((isset($_POST["imageField_x"])&&(!isset($_POST["Rememberme"])) && $_POST["imageField_x"] != "")) {
setcookie("password"""time()+(60*60*24*30), "/"""0);
}
?>
Sign in to reply to this post

amucino12002

Yeah. I got that one by adding a page that clears them on load. That worked.

The last thing here is to clear them when the 'remember me' and 'autologin' checkboxes are unchecked, otherwise it will keep remembering and autologging in without the user's concent.

Sign in to reply to this post

Jason ByrnesWebAssist

see my previous reply for an example of the code to use.

add a set cookie behavior for each cookie to clear, set the value to be blank. you then need to edit the trigger that is used.

this is an example of the trigger code to use:

php:
if ((isset($_POST["imageField_x"])&&(!isset($_POST["Rememberme"])) && $_POST["imageField_x"] != "")) {
Sign in to reply to this post

amucino12002

I tried but adding the behavior as recommended created an error where the page was not displayed at all. attached is how i am adding it with the above code.

Sign in to reply to this post

Jason ByrnesWebAssist

you don't enter that code in the behavior.

you need to edit the trigger code after the behavior has been applied.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...