473,503 Members | 5,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

scope problems.

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.

All ideas are gratefully received.

Cheers,

Steve
Jul 17 '05 #1
2 2247
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

Jul 17 '05 #2
MeerKat wrote:
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.


Hi,

I think you can fix this problem by making a custom session handler. If you
put it in a db, which can be accessed by both servers, you can use the same
sessions. For more information see:
http://www.phpbuilder.com/columns/yi...3?print_mode=1

Kinds regards,

Dirk

--
BOFH Excuse #77:

Typo in the code

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2676
by: Allan Bruce | last post by:
Hi there, I mainly use c for programming but have decided to try and learn c++. I found a text which delcares the following { int *variablePointer; int count = 32; variablePointer = &count;...
9
2514
by: Neelesh | last post by:
I was reading TC++PL (Chapter 11, section 11.5.1 "finding friends") where it is mentioned that What I observe is a bit different - it is fine that there is an error for Xform, but the reason...
5
9360
by: Rouben Rostamian | last post by:
I searched the C99 standard and clc's FAQ but was unable to find an answer to the following issue. I hope that someone here can illuminate me. Suppose I have: enum myenum { enuma, enumb,...
23
5769
by: myth.drannon | last post by:
lets say I have a header file : struct AAAA { blabla..... }; typedef struct AAAA A; typedef struct BBB
9
1373
by: pemo | last post by:
Decided to re-post this as a new /thread/. My comments/question below came up via the 'Seg fault, please help!' post recently made by BT. BT wrote: <snip> >
6
5385
by: Jack | last post by:
I want to write code that can be compiled as C and C++. In the Windows API, there are many macros that help with scope resolution. For example: #ifdef __cplusplus #define SNDMSG ::SendMessage...
7
2098
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
3
10788
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
26
2110
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null);...
3
2454
by: John Dann | last post by:
Trying to learn Python here, but getting tangled up with variable scope across functions, modules etc and associated problems. Can anyone advise please? Learning project is a GUI-based...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.