473,804 Members | 3,607 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 2283
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
2691
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; cout << *variablePointer;
9
2534
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 is not that Xform is not in scope - the reason is that the class's size is not known. Also, the second line is compiling fine - without any problems. In other words, I find that the declaration of a friend function or a class inside a class _does_...
5
9381
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, enumc }; near the top of a file, outside any functions.
23
5828
by: myth.drannon | last post by:
lets say I have a header file : struct AAAA { blabla..... }; typedef struct AAAA A; typedef struct BBB
9
1385
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
5404
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 #else #define SNDMSG SendMessage #endif
7
2118
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 ----------------------------------------------------------------------------- This is a consortium of ideas from another thread on topic ----------------------------------------------------------------------------- One of the big issues of organizing items within a class, is there are many...
3
10843
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 server tables programmatically. The web service builds and deploys with no problems. When I try to add the corresponding Web Reference to the Web Site project I get the error listed below. I am able to create other Web Services on the same server...
26
2154
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); this.property1 = arg; this.property2 = aConstantDefinedGlobally; this.method1 = function (anArg) {
3
2486
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 (wxPython) Python program that needs to access external data across a serial port. The first thing that I need the program to do when it starts up is to check that it can see the serial port, the first step of which is to check that it can import the...
0
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.