[useful] Save login

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [useful] Save login

      Hi~
      My english is no good. sorry...

      It makes logging in easier.
      ID and password storage.
      Activate the save password checkbox when you click save id.
      Have a nace day~~~

      1. File open
      styles\templates\login\page.index.default.tpl

      2.
      Find this code....
      <div style="text-align: right;">
      <button type="submit" class="btn btn-primary">{$LNG.loginButton}</button>
      </div>

      Add code below

      <div class="form-group">
      <input type="checkbox" id="idSaveCheck"/>ID&nbsp;&nbsp;&nbsp;
      <input type="checkbox" disabled id="pwdSaveCheck" class="no_act"/>Password
      </div>

      Add JavaScript code at the end.

      JavaScript Source Code

      1. <script type="text/javascript">
      2. function setCookie(cookieName, value, exdays){
      3. var exdate = new Date();
      4. exdate.setDate(exdate.getDate() + exdays);
      5. var cookieValue = escape(value) + ((exdays==null) ? "" : "; expires=" + exdate.toGMTString());
      6. document.cookie = cookieName + "=" + cookieValue;
      7. }
      8. function deleteCookie(cookieName){
      9. var expireDate = new Date();
      10. expireDate.setDate(expireDate.getDate() - 1); //Set yesterday's date as cookie expiration date
      11. document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString();
      12. }
      13. function getCookie(cookieName) {
      14. cookieName = cookieName + '=';
      15. var cookieData = document.cookie;
      16. var start = cookieData.indexOf(cookieName);
      17. var cookieValue = '';
      18. if(start != -1){
      19. start += cookieName.length;
      20. var end = cookieData.indexOf(';', start);
      21. if(end == -1)end = cookieData.length;
      22. cookieValue = cookieData.substring(start, end);
      23. }
      24. return unescape(cookieValue);
      25. }
      26. $(document).ready(function() {
      27. //Storing Id Cookies
      28. var userInputId = getCookie("userInputId");
      29. $("input[name='username']").val(userInputId);
      30. if($("input[name='username']").val() != ""){
      31. $("#idSaveCheck").attr("checked", true);
      32. $("#pwdSaveCheck").removeAttr("disabled");
      33. }
      34. $("#idSaveCheck").change(function(){
      35. if($("#idSaveCheck").is(":checked")){
      36. //Activate the save pwd checkbox when you click save id
      37. $("#pwdSaveCheck").removeAttr("disabled");
      38. $("#pwdSaveCheck").removeClass('no_act');
      39. var userInputId = $("input[name='username']").val();
      40. setCookie("userInputId", userInputId, 365);
      41. }else{
      42. deleteCookie("userInputId");
      43. $("#pwdSaveCheck").attr("checked", false);
      44. deleteCookie("userInputPwd");
      45. $("#pwdSaveCheck").attr("disabled", true);
      46. $("#pwdSaveCheck").addClass('no_act');
      47. }
      48. });
      49. $("input[name='username']").keyup(function(){
      50. if($("#idSaveCheck").is(":checked")){
      51. var userInputId = $("input[name='username']").val();
      52. setCookie("userInputId", userInputId, 365);
      53. }
      54. });
      55. //Storing password Cookies
      56. var userInputPwd = getCookie("userInputPwd");
      57. $("input[name='password']").val(userInputPwd);
      58. if($("input[name='password']").val() != ""){
      59. $("#pwdSaveCheck").attr("checked", true);
      60. $("#pwdSaveCheck").removeClass('no_act');
      61. }
      62. $("#pwdSaveCheck").change(function(){
      63. if($("#pwdSaveCheck").is(":checked")){
      64. var userInputPwd = $("input[name='password']").val();
      65. setCookie("userInputPwd", userInputPwd, 365);
      66. }else{
      67. deleteCookie("userInputPwd");
      68. }
      69. });
      70. $("input[name='password']").keyup(function(){
      71. if($("#pwdSaveCheck").is(":checked")){
      72. var userInputPwd = $("input[name='password']").val();
      73. setCookie("userInputPwd", userInputPwd, 365);
      74. }
      75. });
      76. });
      77. </script>
      Display All
      Images
      • login.JPG

        34.27 kB, 720×469, viewed 257 times
      --------------------------------------------------------------------------------------
    • go2moons wrote:

      Are you really storing passwords in a cookie ? I would definitely avoid this

      It is the same as the ID saving function of a general website.
      It is saved only on the current device, not on the server.
      Please let me know if there is a problem.
      thank you.
      ^^ ^^
      --------------------------------------------------------------------------------------
    • noonn wrote:

      go2moons wrote:

      Are you really storing passwords in a cookie ? I would definitely avoid this
      It is the same as the ID saving function of a general website.
      It is saved only on the current device, not on the server.
      Please let me know if there is a problem.
      thank you.
      ^^ ^^

      There is a huge difference between saving a random unique id and a password in a cookie.

      Take the case where you are the user and your cookie with password get stolen.
      • Maybe you use the same password on other sites, which access could be stolen as-well which will not be the case with the random generated ID
      To be honest, and maybe i am wrong, the best solution for the persistent login is to save the username/email but never the password. The user should write it over and over again

      Taken from google:

      1. You should never store sensitive data in a cookie, such as user names, passwords, credit card numbers, and so on. Do not put anything in a cookie that should not be in the hands of a user or of someone who might somehow steal the cookie. Similarly, be suspicious of information you get out of a cookie







    • go2moons wrote:

      There is a huge difference between saving a random unique id and a password in a cookie.

      Take the case where you are the user and your cookie with password get stolen.
      • Maybe you use the same password on other sites, which access could be stolen as-well which will not be the case with the random generated ID
      To be honest, and maybe i am wrong, the best solution for the persistent login is to save the username/email but never the password. The user should write it over and over again

      Taken from google:
      1. You should never store sensitive data in a cookie, such as user names, passwords, credit card numbers, and so on. Do not put anything in a cookie that should not be in the hands of a user or of someone who might somehow steal the cookie. Similarly, be suspicious of information you get out of a cookie



      I totally agree with your opinion.
      Storing passwords can be dangerous.
      Thank you for your support.
      ^^
      --------------------------------------------------------------------------------------