faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 89 people (15%) answered Yes
Recently 2 of 10 people (20%) answered Yes


How can I set session information from JavaScript?

Apr 7th, 2008 22:29
ha mo, Colin Fraser, sadaf ahmed,

I am going to define what I would think is "session information" before
going any further, to see if we are thinking about the same thing. A
session begins when someone logs into your site, and ends when they
leave. During their stay all their key strokes and mouse clicks and
places within your site they go to are all recorded in a log file for
later perusal, or as evidence of their doings while in your site. A
great idea, except for a couple of problems...
Firstly is the log file, client-side Javascript does not handle log
files at all, that may be done by server side Javascripts, but I do not
know, never having used server side Javascripts. I have found that PHP
and MySQL handle all that automatically now. 
The reason why I make the distinction between server side and client
side is that browser technology depends on a connectionless state, that
is, the only time when users are really connected to your site is when
they are downloading, as soon as the download is complete, the
connection between the site and the user is broken. 
You can use cookies to establish time of first connection and for every
subsequent connection and disconnection, however, it is all too obvious
that unless cookies are enabled then it is unlikely that this will work.
 Also, there is no guarantee that users will log out of your page, or if
they dont have to, even that they will unload your page, they may simply
close their browser which can make it difficult to set a cookie. 
Someone may have a different view, which is just as valid as anything i
have said here, but I would suggest you seriously consider using PHP and
MySQL, there are a number of sites out there that will tell you how you
can do what you want, or give you something close to what you want, so
you can modify scripts yourself. 
Good luck...