javascript - 网页 下次自动登录如何实现
阿神
阿神 2017-04-10 14:29:42
0
3
588

用cookie 和JS 实现下次自动登录 哪位大大 有例子 贴身上来 学习学习

阿神
阿神

闭关修行中......

reply all(3)
左手右手慢动作
function setCookie(key,value,options){
  var options = options||{};
  if(options.hour){
    var today = new Date();
    var expire = new Date();
    expire.setTime(today.getTime() + options.hour * 3600000);
  }
  window.document.cookie = 
    key + "=" + value
      + (options.path ? "; path=" + options.path : "")
      + (options.hour ? "; expires=" + expire.toGMTString() : "")
      + (options.domain ? "; domain=" + options.domain : "");
  return this;
}
function getCookie(key){
  var reg = new RegExp("(^| )" + key + "=([^;]*)(;|\x24)"),
  result = reg.exec(document.cookie);
  if(result){
    return result[2]||null;
  }
}

然后设置cookie的时间

伊谢尔伦

转载自 coolshell 耗子哥的:

你会做Web上的用户登录功能吗

小葫芦

这不是js可以搞定的. 安全方面的事情都必须后台做, 当然你要是用node做后台就可以用js搞定了....

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template