Steve Holdoway wrote:
Hi there,
Is there any way of defining a variable who lives as long as the
browser stays active? I did some initial tests, and found that the
session variables did this, but now I've developed some software that
requires this, I find that the session id ( for example ) changes
every time you change url to a new server. I think it may have been me
not doing what I should when I set up virtual servers to test this ):
What I'm trying to do is to uniquely define the person on the end of
the keyboard... well, that's the idea, but just identifying the
browser that's running ( ie from the double click to start it to
closing it down, not whether is's Netscape or IE ) would do fine as
well. So, alternatively, is there a way of getting the process id?
That in conjunction with the remote IP addy would be enough.
What you are asking for is (fortunately) impossible. As least, it is
impossible to do if you -must- rely on it. Theoretically, someone's IP
address (which you can get using PHP of course) is unique to their
machine. However, most people are on dialup or are on ADSL (for example)
so they have a dynamic IP address (their address changes every time they
log on to the internet). Or people use proxy servers, so the IP address
may be of that rather than their machine.
Sessions (normally) work using cookies. As cookies are only sent back to
the server that created them, sessions cannot exist across servers.
Server A creates a cookie, server B cannot read it. So what you need is
a method to share cookies across servers.
I'm not going to design some huge complex system, but essentially every
server you need to share information across must set a cookie every time
you hit a page on any of the servers. You do this by including a hidden
graphic on the page from each of the other servers. The graphic is a PHP
-generated one, which sets a cookie. If each of the cookies have the
same ID number, for example, you can therefore identify the same person
as they travel across servers.
But of course, you'd be evil if you did this :)
These are known as web-bugs and are frowned upon. Severely. You really
wouldn't want to do this on a commercial site as I'm sure you'd receive
plenty of complaints. It may be OK in, for example, a closed intranet
type environment, but not sites for the general public.
There are maybe other ways of doing it. This is one method. Personally,
I would seriously ask myself why I wanted to do this and think of some
other way of accomplishing the same thing.
Sorry if this sounds like a brain dump, because that is exactly what it
is :) End of ramble.
Hope at least some of this helps.
--
MeerKat