QuickUser JavaScript Library

QuickUser is a JavaScript class that maintains user information using a cookie. It creates a new user ID, if one wasn't already created, and stores an array of user information in a cookie. Additional key / value pairs can be added by the programmer. No user id or password is required, making login unnecessary. They can be easily added and tracked, however.

Download (quickuser.zip)

In order to use the library, simply include the QuickUser.js file into your HTML document.

<script type="text/javascript" src="quickuser.js"></script>

Then, in your documents JavaScript create an instance of the QuickUser object.

<script type="text/javascript">
 
  // Load a user using the QuickUser class
  user = new QuickUser();
 
  // Read the user ID that was assigned
  var id = user.get("id");
 
  // Read the number of hits
  var hits = user.get("hits");
 
  // Set your own variable
  user.set("first", "Joel");
 
</script>

This source code is distributed under the MIT License.

 
quickuser.txt · Last modified: 2009/09/08 08:37 by Joel Dare
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki