Search DominoPower's 11,437 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
Using cookies in Lotus Domino applications is in your future (continued)

A cookie consists of a cookie name, a cookie value, an expiry date in GMT, a domain for which the cookie applies, a path for which the cookie applies within that domain, and a "secure" setting that, if specified, means that this cookie can only be sent over secure connections (HTTPS).

Every time the Web browser accesses the URL and path from which the cookie came, it sends the cookies back to the Web server. The contents of the cookie are then made available to the page requested by the Web browser.

If you do a search on your hard disk for cook*.* you should find the directory in which the cookies are stored. The filenames end in the domain name of the site that the cookie came from. You can open these cookie files in an editor to see the structure of the cookies and their contents.

Recipe for making cookies in Domino
Fortune cookie says: "Good things are coming to you in due course of time."

Cookies are easy. You only need a Javascript function and a couple of fields to read the cookie values, and you're done.

We are now going to build a Domino application that demonstrates how to create and read cookies.

Here is what our completed demonstration application will do:

  • Display the current value of the cookie;
  • Display a dropdown field allowing selection of a new value for the cookie;
  • When the dropdown field value is changed, call the Javascript function for changing the cookie value;
  • The page is then refreshed to update the current cookie value.

Ingredients
Here are the ingredients needed to create cookies:

  • One Javascript function for creating cookies at the client end;
  • One field on the form, named HTTP_COOKIE;
  • One field on the form that extracts the required information from HTTP_COOKIE;
  • One dropdown field that calls the Javascript function for creating or changing the cookie value.

Cooking instructions:
Create a new, blank Lotus Domino database, giving it whatever name you want.

In the database properties, turn off "Web access: Use Javascript when generating pages".

Create a new form and name it "Demo".

In the form properties, make sure that "Treat document contents as HTML" is turned off.

The Javascript SetCookie function
The Javascript SetCookie function does only three things. It first validates and parses the cookie expiry data/time (if present), and then executes the method that creates the cookie. Finally, the page is refreshed.

Add the following Javascript to the top of the form:

<script>

function SetCookie(cookiename, cookievalue){
// we'll set the expiry date to be in the year 2010
var expirydate = new Date();
expirydate.setYear(2010);

//now set the cookie
document.cookie = cookiename + "=" + escape(cookievalue) + "; expires=" + expirydate.toGMTString();

window.location.reload( true );

}

</script>


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  6  ·  Next »
Other articles you might like
Home > Internet Technologies > JavaScript (13 articles)
   Sorting your Domino views with JavaScript
   Give your Domino views life with DHTML
   Using dynamically generated HTML to thwart spam email address harvesting
Home > Internet Technologies > Cookies (2 articles)
   Where cookie comes from
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
Adding Quick Highlighter support to IBM Lotus Notes Domino Wiki, Weblog, or Webpage
Remember Young Admins...there are 2 files
WebSphere Portal 6.1.0.2 and Lotus Domino 8.5
The CKEditor - with Domino
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done. Native to Lotus Domino. The User Experience unseen for Lotus Domino. Do more with less. Really.

See the possibilities Docova unleashes for Lotus Domino.
-- Advertisement --

Teamstudio Edition 25 has shipped
It's finally here! Now that Teamstudio Edition 25 has shipped, listen to our latest Tool Time audio program to find out what's changed. Updates to all your favorite Teamstudio tools will be discussed.

Plus, you'll get an introduction to Teamstudio Undo (formerly known as Teamstudio Snapper).

Tap here to get started!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login