473,602 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Another Session Question - Overlaps?

Let's say I run a server. I have two people using the server. Bill and Joe.
Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages.
Let's say they both create the session variable $_SESSION['yo']. Each uses
yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is
lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session
data?

Thank you again, I know I have a lot of questions.
Jul 16 '05 #1
9 2981
Xizor wrote:
Let's say I run a server. I have two people using the server. Bill and Joe.
Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages.
Let's say they both create the session variable $_SESSION['yo']. Each uses
yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is
lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session
data?

Thank you again, I know I have a lot of questions.

Is this a hypothetical question? I don't see why this would actually
happen. The Session ID--which tells PHP which temp session file to
open--is either a) part of the URL or b) stored as a cookie on the
client's machine. The session_start() function should figure out which
file to open and as such, have the correct instance of _SESSION.

Again, this is what I perceive to be the intended behavior, but if
you've experienced something contradictory, then the above paragraph is
of absolutely no consequence to you, and I apologize for wasting your
time :)

Jul 16 '05 #2

"Joshua Ghiloni" <jd***@SPAM.ME. AND.DIE.cwru.ed u> wrote in message
news:bf******** **@eeyore.INS.c wru.edu...
Xizor wrote:
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages. Let's say they both create the session variable $_SESSION['yo']. Each uses yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session data?

Thank you again, I know I have a lot of questions.

Is this a hypothetical question? I don't see why this would actually
happen. The Session ID--which tells PHP which temp session file to
open--is either a) part of the URL or b) stored as a cookie on the
client's machine. The session_start() function should figure out which
file to open and as such, have the correct instance of _SESSION.


I don't think it is hypothetical. It would happen as far as I can tell. If a
user opens his browser and goes to Bill's site then that same user goes to
Joe's site, since both are running off the same domain, well then
session_start() will invoke the same cookie, hence the same session ID,
hence the same temp file, both from Bill's web site and Joe's.
Jul 16 '05 #3
Your understanding of PHP sessions is incomplete. Using your example
'yo' is simply a variable within the current session, but each time a
user accesses your site with his browser a new session is created with
a unique session id. This means that multiple users can access your
site and have a value for the 'yo' variable, but as each user has a
different session he also has a different copy of those session
variables.

If you look in the directory where you have directed PHP to store its
session files you will see a different file for each session where the
filename is the same as the session id.

Hope this helps.

Tony Marston
http://www.tonymarston.net/
"Xizor" <no**@nope.co m> wrote in message news:<uL2Ra.736 33$Ph3.7579@scc rnsc04>...
Let's say I run a server. I have two people using the server. Bill and Joe.
Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages.
Let's say they both create the session variable $_SESSION['yo']. Each uses
yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is
lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session
data?

Thank you again, I know I have a lot of questions.

Jul 16 '05 #4
Xizor wrote:
Question: What is the best way to stop this unintentional overlapping
of session variables? Is there a way of maintaining separate sets of
session data?


Hmm...

Maybe you could try setting session cookie path with
session_set_coo kie_params()?

So your session var would be valid only in directory you want...

--
--- --- --- --- --- --- ---
ja**@croatiabiz .com
Jul 16 '05 #5
What would happen should the user be visiting Bill's pages and then directly
type the URL or clicked a bookmark which took them to Joe's site which was
using cookies?

Surely because the browser has remained open throughout the visit from
Bill's site to Joe's site then the Session ID would remain the same and all
variables associated with Bill's site would be passed to Joe and vice versa.

I am not expert but that is the way I perceive the Session system to work
under PHP.

HTH,

Paul Woodward
===
"Tony Marston" <to**@marston-home.demon.co.u k> wrote in message
news:75******** *************** ***@posting.goo gle.com...
Your understanding of PHP sessions is incomplete. Using your example
'yo' is simply a variable within the current session, but each time a
user accesses your site with his browser a new session is created with
a unique session id. This means that multiple users can access your
site and have a value for the 'yo' variable, but as each user has a
different session he also has a different copy of those session
variables.

If you look in the directory where you have directed PHP to store its
session files you will see a different file for each session where the
filename is the same as the session id.

Hope this helps.

Tony Marston
http://www.tonymarston.net/
"Xizor" <no**@nope.co m> wrote in message

news:<uL2Ra.736 33$Ph3.7579@scc rnsc04>...
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages. Let's say they both create the session variable $_SESSION['yo']. Each uses yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session data?

Thank you again, I know I have a lot of questions.

Jul 16 '05 #6
Xizor wrote:
"Joshua Ghiloni" <jd***@SPAM.ME. AND.DIE.cwru.ed u> wrote in message
news:bf******** **@eeyore.INS.c wru.edu...
Xizor wrote:
Let's say I run a server. I have two people using the server. Bill and
Joe.
Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web
pages.
Let's say they both create the session variable $_SESSION['yo']. Each
uses
yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and
all is
lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of
session
data?

Thank you again, I know I have a lot of questions.


Is this a hypothetical question? I don't see why this would actually
happen. The Session ID--which tells PHP which temp session file to
open--is either a) part of the URL or b) stored as a cookie on the
client's machine. The session_start() function should figure out which
file to open and as such, have the correct instance of _SESSION.

I don't think it is hypothetical. It would happen as far as I can tell. If a
user opens his browser and goes to Bill's site then that same user goes to
Joe's site, since both are running off the same domain, well then
session_start() will invoke the same cookie, hence the same session ID,
hence the same temp file, both from Bill's web site and Joe's.


Then my best suggestion would be to come up with more original session
variables ;) Since they're just keys of an array, and a key can be a
string, why not make the variable $_SESSION["joe_yo"] and
$_SESSION["bill_yo"] instead of $_SESSION["yo"]. Using global variables
like this--multiple global variables with the same name in different
programs--is always an issue.

Jul 16 '05 #7
Rod
Hi,

you can do that:

in Bill'site:
session_name("B ILL");
session_start() ;

in Joe's site:
session_name("J OE");
session_start() ;

so even with the same user/browser you will use a different set of session
data for each site

brgds
"Xizor" <no**@nope.co m> wrote in message
news:uL2Ra.7363 3$Ph3.7579@sccr nsc04...
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages. Let's say they both create the session variable $_SESSION['yo']. Each uses
yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session
data?

Thank you again, I know I have a lot of questions.

Jul 16 '05 #8
I'll try this. Thanks.

"Rod" <to**@toto.co m> wrote in message news:bf******** **@home.itg.ti. com...
Hi,

you can do that:

in Bill'site:
session_name("B ILL");
session_start() ;

in Joe's site:
session_name("J OE");
session_start() ;

so even with the same user/browser you will use a different set of session
data for each site

brgds
"Xizor" <no**@nope.co m> wrote in message
news:uL2Ra.7363 3$Ph3.7579@sccr nsc04...
Let's say I run a server. I have two people using the server. Bill and Joe.
Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web

pages.
Let's say they both create the session variable $_SESSION['yo']. Each uses yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is
lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of

session data?

Thank you again, I know I have a lot of questions.


Jul 16 '05 #9
"Paul Woodward" <no*****@newsgr oups.com> wrote in message news:<3f******* *************** *@news.dial.pip ex.com>...
What would happen should the user be visiting Bill's pages and then directly
type the URL or clicked a bookmark which took them to Joe's site which was
using cookies?

Surely because the browser has remained open throughout the visit from
Bill's site to Joe's site then the Session ID would remain the same and all
variables associated with Bill's site would be passed to Joe and vice versa.
The PHP session id is stored in a cookie, and as cookies are limited
to a particular site there will be a different cookie, therefore a
different session, for each site you visit.

Apart from this the session contents are maintained on the server, not
the client, so any session data that is saved on Bill's site is not
available on Joe's server, and vice versa. The session data for Bill's
site is therefore totally separate from the session data on Joe's
site.

Tony Marston
http://www.tonymarston.net/
I am not expert but that is the way I perceive the Session system to work
under PHP.

HTH,

Paul Woodward
===
"Tony Marston" <to**@marston-home.demon.co.u k> wrote in message
news:75******** *************** ***@posting.goo gle.com...
Your understanding of PHP sessions is incomplete. Using your example
'yo' is simply a variable within the current session, but each time a
user accesses your site with his browser a new session is created with
a unique session id. This means that multiple users can access your
site and have a value for the 'yo' variable, but as each user has a
different session he also has a different copy of those session
variables.

If you look in the directory where you have directed PHP to store its
session files you will see a different file for each session where the
filename is the same as the session id.

Hope this helps.

Tony Marston
http://www.tonymarston.net/
"Xizor" <no**@nope.co m> wrote in message

news:<uL2Ra.736 33$Ph3.7579@scc rnsc04>...
Let's say I run a server. I have two people using the server. Bill and Joe. Bill is at address.com/bill and Joe is at address.com/joe.

Let's say Joe and Bill are both using PHP with sessions on their web pages. Let's say they both create the session variable $_SESSION['yo']. Each uses yo for a different purpose.

Now we have a user accessing address.com. He goes to Bill's site and his
session his started with the $_SESSION['yo'] created.

But then the user sees Joe's site, and he goes to it without closing his
browser. Joe's script sees that $_SESSION['yo'] exists and uses it. But
wait, it has bad data from Bill's site. Oh no! The world explodes and all is lost.

Question: What is the best way to stop this unintentional overlapping of
session variables? Is there a way of maintaining separate sets of session data?

Thank you again, I know I have a lot of questions.

Jul 16 '05 #10

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

Similar topics

2
3946
by: axion_sa | last post by:
Hi, What I have is a booking table, and when updating/inserting I need to ensure that there are no date/time overlaps. The problem I'm having is that while the following script works for events on the same day, it fails miserably when a booking starts on a previous day.
0
4511
by: Red | last post by:
See http://reenie.org/test9.php There are two examples each with three nested divs. The only difference between the two is that the first example has no padding in the inner div, the second has 10px padding in the inner div. The middle div has no padding and its black background should not show up at all.
1
1787
by: Mark Carroll | last post by:
With this page, <HTML> <HEAD><TITLE>Test page</TITLE></HEAD> <BODY STYLE="color: black; background: white"> <TABLE STYLE="float: left; clear: both"><TR> <TD STYLE="background: blue; width: 500px; height: 500px">Foo</TD> </TR></TABLE> <TABLE STYLE="float: right; clear: both"><TR> <TD STYLE="background: green; width: 500px; height: 500px">Bar</TD>
12
1951
by: Patrick | last post by:
I have two ASP pages payment.asp: For customers to fill in payment/card details (pre-populating details if details submitted were invalid and user had to re-fill in details) confirmorder.asp: Display the credit card details in hidden fields and also the order details from Database My question is
20
1694
by: Andrew Poulos | last post by:
If I have a page with a bunch of content and some javascript in the head how do I notify the javascript disabled users that enabling javascript would enhance their experience. At the moment I'm trying the noscript tag but its content overlaps the "normal" content. I'd like to put a link to non-javascript pages and I'd rather not put the normal content in a document.write. Andrew Poulos
2
2380
by: Boban Dragojlovic | last post by:
I'm building a complex web-based reservations system. Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to store the various elements as the user moves through the pages. Rather than storing the preferences directly in the Session object (e.g. Session("LastName") = ...), I created a class <Serializable()> Public Class ReservationInfo
9
1386
by: Varangian | last post by:
Hello is there a way to check if an image is over another Image ? thanks
17
7064
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the returned value is "" Anybody know how to set this value on 1st page properly, in order to let 2nd page catch it? I don't want to use querystring to pass this value!
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
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
8054
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,...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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
3900
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...
1
2418
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 we have to send another system
0
1254
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.