473,379 Members | 1,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 2963
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.edu> wrote in message
news:bf**********@eeyore.INS.cwru.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.com> wrote in message news:<uL2Ra.73633$Ph3.7579@sccrnsc04>...
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_cookie_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.uk> wrote in message
news:75**************************@posting.google.c om...
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.com> wrote in message

news:<uL2Ra.73633$Ph3.7579@sccrnsc04>...
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.edu> wrote in message
news:bf**********@eeyore.INS.cwru.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("BILL");
session_start();

in Joe's site:
session_name("JOE");
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.com> wrote in message
news:uL2Ra.73633$Ph3.7579@sccrnsc04...
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.com> wrote in message news:bf**********@home.itg.ti.com...
Hi,

you can do that:

in Bill'site:
session_name("BILL");
session_start();

in Joe's site:
session_name("JOE");
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.com> wrote in message
news:uL2Ra.73633$Ph3.7579@sccrnsc04...
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*****@newsgroups.com> wrote in message news:<3f***********************@news.dial.pipex.co m>...
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.uk> wrote in message
news:75**************************@posting.google.c om...
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.com> wrote in message

news:<uL2Ra.73633$Ph3.7579@sccrnsc04>...
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
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...
0
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...
1
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:...
12
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:...
20
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...
2
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...
9
by: Varangian | last post by:
Hello is there a way to check if an image is over another Image ? thanks
17
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.