Page 1 of 1

Login object - remember me

Posted: Thu Aug 23, 2018 10:30 pm
by alex4orly
I look at the code generated here by WWB, at the end of it there are 2 lines

setcookie('username', $_POST['username'], time() + 3600*24*30);
setcookie('password', $_POST['password'], time() + 3600*24*30);

Then, after that:
$username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
$password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';

1) It seems that there are 2 cookies created, why? Can't I create a cookie with several elemnts in it?
2) I want to store the flag $active 0 or 1 in it to be interrogated at log in time, do I need a 3rd cookie for that?

Cheers

Re: Login object - remember me

Posted: Fri Aug 24, 2018 6:52 am
by Pablo
You can find more information about setcookie here:
http://php.net/manual/en/function.setcookie.php

Re: Login object - remember me

Posted: Fri Aug 24, 2018 8:32 am
by alex4orly
This answers my first question, from the article I can see how to have multiple elemnt in ONE Cookie, but

1) Whay is that not used in the PHP code generated by WWB when using the Login object?
2) What is the purpose of the final two lines? Is that just so that those values become available to subsequent pages? If this is the case, I can consider what to do. Please let me know

Thanks

Re: Login object - remember me

Posted: Fri Aug 24, 2018 9:28 am
by Pablo
I just choose to implement it this way. If do not like it this way then you can write your own code.
The code puts the cookie value into a PHP variable.

Please note that I generally do not discuss generated code. This is beyond the scope of this forum.