[ic] Inelegant greeting...

Dave Barr dave.barr@cricinfo.com
Wed, 15 Nov 2000 11:23:47 +0000

IC 4.6, Debian 2.2.17, MySQL 3.22.32, CVS 1.10.7, Perl 5.005-03, PGP 7.0

Hi all,

Its Captain pedantic again  ;)
I have been attempting to greet users who have set cookies at 
user-account creation time on their "entry" page to avoid confusion. 
To explain; the cookie will only "kick-in" on the second page that 
any user enters, during in-house testing this was the number one 
complaint/comment that people made. They expected on their *entry* 
page to have some form of acknowledgement that the server knew who it 
was dealing with, most selected to go to the login page only to find 
that once they had done so the server had picked them up... Its a 
small point but I had to concur that as small as it is the point was 
valid. I came up with the following (reduced for readability);
<!-- HIDE
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
     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.length;
   var i = 0;
   while (i < clen) {
     var j = i + alen;
     if (document.cookie.substring(i, j) == arg)
       return getCookieVal (j);
       i = document.cookie.indexOf(" ", i) + 1;
       if (i == 0) break;
   return id = "null";
var id = GetCookie('MV_USERNAME');
// END -->


[if !session logged_in]
<!-- HIDE
if (id != 'null') {
//document.write("[data table=userdb column=fname key=\'"+id+"\']");
   document.write("Hi "+id+" welcome back to __COMPANY__.");
// END -->

I was wondering if anyone has come up with a more elegant solution? 
Also, the first document.write incorporating the read of the userdb 
table failed to work (with either plain ASCII being displayed or 
nothing at all), I seem to remember from the dim and distant past a 
way of forcing tags to compile in an order that would allow this to 
work (I failed to find it in either the dox or mailist)... I could of 
course be mistaken...  :)

Just another quick thanks to Mike and the Akopia team for the great 
work, and any comments on the above most welcome...