JS Record User Login number implementation code

Source: Internet
Author: User
Tags set cookie setcookie

  When the logon count reaches three times, the function is automatically invoked, and the pop-up box is hidden. The following is a specific implementation, interested friends can refer to the following

The code is as follows: function www_helpor_net (offset) {  var endstr = document.cookie.indexOf (";", offset);  if (endstr = 1) & nbsp Endstr = document.cookie.length;  return unescape (document.cookie.substring (offset, endstr)); }  function GetCookie (name) {  var arg = name + "=";  var alen = arg.length;  var Clen = Document.cookie.lengt h;  var i = 0;  while (i < Clen) {  var j = i + alen;  if (document.cookie.substring (i, j) = Arg) & nbsp Return Www_helpor_net (j);  i = document.cookie.indexOf ("", I) + 1;  if (i = 0)   break; }  RN null; }    function Setcookie (name, value) {  var argv = setcookie.arguments;  var argc = Set cookie.arguments.length;  var expires = (2 < ARGC)? ARGV[2]: null;  var path = (3 < ARGC)? ARGV[3]: null;  var domain = (4 < ARGC)? ARGV[4]: null;  var secure = (5 < ARGC)? ARGV[5]: false;  document.cookie = name  + "="   + Escape (value)   + ((expires = null)? "" : ("; Expires= "+ expires . toGMTString ()))   + ((path = null)? "" : ("; Path= "+ path")   + ((domain = null)? "" : ("; domain= "+ domain")   + ((secure = = True)? "; Secure ":" ""); }  var expdate = new Date ();  var visits;  expdate.settime (Expdate.gettime () + (24 * 6 0 * 60 * 1000 * 365)); Set the cookie time for 1 years, you set the time casually   if (! visits = GetCookie ("visits")) {  visits = 0; }  var Oldjessionid = GetCookie ("Oldjsessionid");  if ( !oldjessionid) {  Oldjessionid = "; }  var Newjessionid = GetCookie (" Jsessionid ");  if (Oldjessi Onid!= Newjessionid) {  visits++;  setcookie ("Oldjsessionid", Newjessionid, Expdate, "/", NULL, FALSE);  Setcookie ("Visits", visits, Expdate, "/", NULL, False); }   //The following information shows that you can use the standard HTML syntax, set your own free     document.write ("You have come to this page" + "<font color=red>" + visits + "</FONT>" + "Times! ");   //When the logon count reaches three times, the function is automatically invoked, the pop-up box is hidden, and if you log the number of logons, the bottom code can ignore   if (Visits > 3) {  setinterval ("Changeh" Down ') ", 2; } */   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.