The following code simulates a login screen. If the check box labeled "Remember me" is checked, upon login a cookie containing the login information is saved onto the user's computer. When he or she revisits the site, the login fields will be filled in automatically.
' Cookies by Javascript
' By Brent D. Thorn, 2/2008
' Revised 9/2008 for RB 1.01
' Revised 1/2009 to simplify the code
 
[start]
    Cls
    Call enableCookies
 
    HTML "<h1>Please log in.</h1>"
 
    Print "Username:"
    TextBox #user, ""
    Print
 
    Print "Password:"
    PasswordBox #pass, ""
    Print
 
    Checkbox #reme, "Remember me", 0
    Print
    Button #login, "Log in", [logIn]
 
   HTML "
<script type=""text/javascript"">
<!--
  if (getCookie('reme')) {
    var user = document.getElementById('#user');
    var pass = document.getElementById('#pass');
    var reme = document.getElementById('#reme');
 
    user.value = getCookie('user');
    pass.value = getCookie('pass');
    reme.checked = true;
  }
//-->
</script>"
 
    Wait
 
[logIn] 
    user$ = #user Contents$() 
    pass$ = #pass Contents$() 
    reme = #reme Value() 
 
    'TODO: Authenticate user. 
 
    Cls 
    Call enableCookies 
 
    HTML "<h1>Welcome, "+user$+"!</h1>" 
 
    If reme Then 
        ' Save info in a cookie. 
        HTML " 
<script type=""text/javascript""> 
<!-- 
  var path = ''; // root 
  var expire = days(30); 
  setCookie('reme', true, path, expire); 
  setCookie('user', '"+user$+"', path, expire); 
  setCookie('pass', '"+pass$+"', path, expire); 
//--> 
</script>" 
 
    Else 
        ' Delete info from cookie. 
        HTML " 
<script type=""text/javascript""> 
<!-- 
  var path = ''; // root 
  delCookie('reme', path); 
  delCookie('user', path); 
  delCookie('pass', path); 
//--> 
</script>" 
    End If 
 
    Link #logout, "Log out", [logOut] 
 
    Wait 
 
[logOut] 
    Cls 
 
    HTML "<h1>Come back soon!</h1>" 
    Link #again, "Log in again", [start] 
 
    Wait 
 
Sub enableCookies 
    HTML " 
<script type=""text/javascript""> 
<!-- 
function getCookie(name) { 
  var dc = document.cookie; 
  var cname = name + ""=""; 
  var clen = dc.length; 
  var cbegin = 0; 
  while (cbegin < clen) { 
    var vbegin = cbegin + cname.length; 
    if (dc.substring(cbegin, vbegin) == cname) { 
      var vend = dc.indexOf("";"", vbegin); 
      if (vend == -1) vend = clen; 
      return unescape(dc.substring(vbegin, vend)); 
    } 
    cbegin = dc.indexOf("" "", cbegin) + 1; 
    if (cbegin == 0) break; 
  } 
  return null; 
} 
function setCookie(name, value, path, expires) { 
  if (!expires) expires = new Date(); 
  document.cookie = name+""=""+escape(value)+""; " +_ 
                    "expires=""+expires.toGMTString()+""; " +_ 
                    "path=/""+path; 
} 
function delCookie(name, path) { 
  document.cookie = name+""=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/""+path; 
} 
function days(num) { 
  var d = new Date(); 
  d.setTime(d.getTime()+(86400000*num)); 
  return d; 
} 
//--> 
</script>" 
 
End Sub