Javascript Operator corrections and Brief Description of Cookies

Cookies and Functions

In my research I could find no other reasonable way to remember information on a session to session basis without using cookies. You can pass information from one frame to another without cookies, but once you have them mastered you can also use them for frame to frame information sharing.

For those of you who haven't read the section in the book about cookies, a cookie is a small file which is associated with a URL. Each URL only stores one cookie ( but can contain multiple pieces of information along with multiple expiration dates for each piece of info. Cookies can be very easy to use by implementing functions to read a cookie (if it exists), and store/update a cookie. We used SetCookie(name, value); and GetCookie(name); (returns value). Full details are forthcoming.

Cookie use by this website

In our implementation we used two cookies, the first called 'id' has an expiration of 7 days and the value of id is your name. the second, called "checked" has an expiration time of 10 minutes and if present (not expired) indicates you have entered your id in the last 10 minutes. Ideally we should update this expiration time as you do things, but we didn't include that.

Name/Id Checking

We have included some code to check that you really entered a name (we expect a name to have 5 or more characters, we know this of course is not always true, but it is a good example of how web programmers screw up. (I hate it when I can't enter my phone number as aaa-xxx-yyyyy or (aaa)xxx-yyyy when some websites want aaaxxxyyyy AND don't even make it clear.

Links "visited" a mystery unraveled!

In reviewing cookies we found the answer to a question which has perplexed us since even before this course. Specifically, Looking at the '<A>' tag, there is normally a different color for targets that have been visited vs those that have not been visited.

Obviously this info must be stored somewhere outside the HTML file. It doesn't appear to be a cookie, as I cleared cookies and I still see different colors. The answer (I found out today) is the IE 'Internet Temporary Files Folder' (if you are using Internet Explorer, recent versions) has cookies and the full copy of pages you have visited recently.

If you want to clear the links "visited" indicator it can be done by deleting the appropriate file in the mentioned directory or by updating the date modified field on the web copy of the file. If you clear cookies alone, it does not delete the files that indicate "visited".

Logical Operators - an explanation

Correction to book
On page h.03 of our book they define ! as a logical NOT, then define | as a negaton (true if expression was false and false if expression was true). This second description also defines a logical NOT. Another reference http://www.devguru.com/Technologies/ecmascript/quickref/bitwise_operators.html describes | as a bitwise OR operator. This is consistent with C and makes more sense. Is the book wrong?

In our research we could not find a negaton in reference to computer programming, or any logical operation. Even google doesn't find a related definition.

Some examples of logical operators

The arithmetic bitwise OR: | =arithmetic result


| is a bitwise arithmetic operator (an OR) in Javascript or C++ or many other languages, it requires two operands that is (A|B) is a valid expression which will yield (in javascript) an arithmetic, not logical result,


The logical NOT: ! =logical result


Conversely, the expression (|A), or (|false) is not a valid JavaScript expression.




An other arithmetic OR


Again, you can not use the expression |false, it is illegal in javascript (the whole statement is ignored), !false is ok and returns a true. In addition to my empirical findings, I was attracted to the so called "negaton" because it makes no sense either from a Boolean logic point of view nor from a computer logic point of view.

Summary: