Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with conflicting sessions

Dave
Guest
 
Posts: n/a
#1: Jul 1 '08
Hopefully this is an easy question for those with more experience.

I have two separate programs that I want to use together on a website

Program A starts first and calls session_start().

Program B is started by the user clicking on a link and it also calls
session_start().

The session started by program B blows away the session started by program
A and program A will not work any longer.

How can I have two independent sessions that don't interfere with each
other?

Any advice or code snippets would be appreciated.

Thanks,
Dave

AnrDaemon
Guest
 
Posts: n/a
#2: Jul 1 '08

re: Help with conflicting sessions


Greetings, Dave.
In reply to Your message dated Tuesday, July 1, 2008, 23:53:10,
Quote:
Hopefully this is an easy question for those with more experience.
Quote:
I have two separate programs that I want to use together on a website
What you calling "programs" at first?
Quote:
Program A starts first and calls session_start().
Quote:
Program B is started by the user clicking on a link and it also calls
session_start().
Quote:
The session started by program B blows away the session started by program
A and program A will not work any longer.
Can you please illustrate it in more presentable way?
I can't understand, how it is possible.
Quote:
How can I have two independent sessions that don't interfere with each
other?
They are independent for sure.
Even more, new session will be started every time until you start to store
something in it.
Quote:
Any advice or code snippets would be appreciated.
Kidding? You haven't explained anything, you haven't provided any example
illustrating your problem...
What do you expect from us? We not gonna do your work for you.


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

Dave
Guest
 
Posts: n/a
#3: Jul 2 '08

re: Help with conflicting sessions


AnrDaemon <anrdaemon@freemail.ruwrote in
news:373384186.20080702003356@freemail.ru:
Quote:
Greetings, Dave.
In reply to Your message dated Tuesday, July 1, 2008, 23:53:10,
>
Quote:
>Hopefully this is an easy question for those with more experience.
>
Quote:
>I have two separate programs that I want to use together on a website
>
What you calling "programs" at first?
>
Quote:
>Program A starts first and calls session_start().
>
Quote:
>Program B is started by the user clicking on a link and it also calls
>session_start().
>
Quote:
>The session started by program B blows away the session started by
>program A and program A will not work any longer.
>
Can you please illustrate it in more presentable way?
I can't understand, how it is possible.
>
Quote:
>How can I have two independent sessions that don't interfere with
>each other?
>
They are independent for sure.
Even more, new session will be started every time until you start to
store something in it.
>
Quote:
>Any advice or code snippets would be appreciated.
>
Kidding? You haven't explained anything, you haven't provided any
example illustrating your problem...
What do you expect from us? We not gonna do your work for you.
>
>
I don't want anyone to do my work for me, that's not it at all. Sometimes
a picture is worth a thousand works and a code fragment might make a
concept clearer than a narrative.

There are two working html files using PHP that I am trying to bundle
togther on one webpage using frames. The outer frame is the main part of
the page but it requires you to login and it creates a session. The
inner frame is a web-based email program that also requires you to login
and authenticate and it starts a session. This session seems to
overwrite the original one and the main program no longer works.

The question is: is there a way to establish two independent sessions
from one html/php script?

Thanks,
Dave
Jerry Stuckle
Guest
 
Posts: n/a
#4: Jul 2 '08

re: Help with conflicting sessions


Dave wrote:
Quote:
Hopefully this is an easy question for those with more experience.
>
I have two separate programs that I want to use together on a website
>
Program A starts first and calls session_start().
>
Program B is started by the user clicking on a link and it also calls
session_start().
>
The session started by program B blows away the session started by program
A and program A will not work any longer.
>
How can I have two independent sessions that don't interfere with each
other?
>
Any advice or code snippets would be appreciated.
>
Thanks,
Dave
>
Dave,

Are you looking at the same domain? If so, they should have the same
session. But that shouldn't be a problem - just store the variables you
want in the apporpriate $_SESSION values (use arrays within the
$_SESSION array to keep things cleaner).

If they are two different domains (remember - www.example.com and
example.com are considered "different" by default), you should already
have two sessions.

But without any code, it's hard to tell what you're doing. So it's even
more difficult to see what's wrong.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Johnny
Guest
 
Posts: n/a
#5: Jul 2 '08

re: Help with conflicting sessions


Jerry Stuckle wrote:
Quote:
Dave wrote:
Quote:
>Hopefully this is an easy question for those with more experience.
>>
>I have two separate programs that I want to use together on a website
>>
>Program A starts first and calls session_start().
>>
>Program B is started by the user clicking on a link and it also calls
>session_start().
>>
>The session started by program B blows away the session started by
>program A and program A will not work any longer.
>>
>How can I have two independent sessions that don't interfere with each
>other?
>>
>Any advice or code snippets would be appreciated.
>>
>Thanks,
>Dave
>>
>
Dave,
>
Are you looking at the same domain? If so, they should have the same
session. But that shouldn't be a problem - just store the variables you
want in the apporpriate $_SESSION values (use arrays within the
$_SESSION array to keep things cleaner).
>
If they are two different domains (remember - www.example.com and
example.com are considered "different" by default), you should already
have two sessions.
>
But without any code, it's hard to tell what you're doing. So it's even
more difficult to see what's wrong.
>
One thing to note is that sessions are lost when the url is not
relative, see here:
http://us.php.net/manual/en/session.idpassing.php

Also if you are accessing session from included files the way they are
called can lose the session. For instance if url includes are allowed
and you do from a file with session_start() already called:
include "/var/www/htdocs/file1.php";
include "http://sameSite/file2.php";

the session will be available in file1 but not in file2
Jerry Stuckle
Guest
 
Posts: n/a
#6: Jul 2 '08

re: Help with conflicting sessions


Johnny wrote:
Quote:
Jerry Stuckle wrote:
Quote:
>Dave wrote:
Quote:
>>Hopefully this is an easy question for those with more experience.
>>>
>>I have two separate programs that I want to use together on a website
>>>
>>Program A starts first and calls session_start().
>>>
>>Program B is started by the user clicking on a link and it also calls
>>session_start().
>>>
>>The session started by program B blows away the session started by
>>program A and program A will not work any longer.
>>>
>>How can I have two independent sessions that don't interfere with
>>each other?
>>>
>>Any advice or code snippets would be appreciated.
>>>
>>Thanks,
>>Dave
>>>
>>
>Dave,
>>
>Are you looking at the same domain? If so, they should have the same
>session. But that shouldn't be a problem - just store the variables
>you want in the apporpriate $_SESSION values (use arrays within the
>$_SESSION array to keep things cleaner).
>>
>If they are two different domains (remember - www.example.com and
>example.com are considered "different" by default), you should already
>have two sessions.
>>
>But without any code, it's hard to tell what you're doing. So it's
>even more difficult to see what's wrong.
>>
One thing to note is that sessions are lost when the url is not
relative, see here:
http://us.php.net/manual/en/session.idpassing.php
>
That's only if you're not using cookies. When using cookies (which
virtually everyone does), absolute or relative urls are immaterial - as
long as the domain itself is the same.
Quote:
Also if you are accessing session from included files the way they are
called can lose the session. For instance if url includes are allowed
and you do from a file with session_start() already called:
include "/var/www/htdocs/file1.php";
include "http://sameSite/file2.php";
>
the session will be available in file1 but not in file2
>
True, if you do a url include. However - why would you ever do that on
your own site? It requires an additional call to the server and
additional server processing. It's much better to include it as a file
- in which case the session information is available.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Dave
Guest
 
Posts: n/a
#7: Jul 2 '08

re: Help with conflicting sessions


Jerry Stuckle <jstucklex@attglobal.netwrote in news:g4fneo$dc$1
@registered.motzarella.org:
Quote:
Johnny wrote:
Quote:
>Jerry Stuckle wrote:
Quote:
>>Dave wrote:
>>>Hopefully this is an easy question for those with more experience.
>>>>
>>>I have two separate programs that I want to use together on a
website
Quote:
Quote:
Quote:
>>>>
>>>Program A starts first and calls session_start().
>>>>
>>>Program B is started by the user clicking on a link and it also
calls
Quote:
Quote:
Quote:
>>>session_start().
>>>>
>>>The session started by program B blows away the session started by
>>>program A and program A will not work any longer.
>>>>
>>>How can I have two independent sessions that don't interfere with
>>>each other?
>>>>
>>>Any advice or code snippets would be appreciated.
>>>>
>>>Thanks,
>>>Dave
>>>>
>>>
>>Dave,
>>>
>>Are you looking at the same domain? If so, they should have the same
>>session. But that shouldn't be a problem - just store the variables
>>you want in the apporpriate $_SESSION values (use arrays within the
>>$_SESSION array to keep things cleaner).
>>>
>>If they are two different domains (remember - www.example.com and
>>example.com are considered "different" by default), you should
already
Quote:
Quote:
Quote:
>>have two sessions.
>>>
>>But without any code, it's hard to tell what you're doing. So it's
>>even more difficult to see what's wrong.
>>>
>One thing to note is that sessions are lost when the url is not
>relative, see here:
>http://us.php.net/manual/en/session.idpassing.php
>>
>
That's only if you're not using cookies. When using cookies (which
virtually everyone does), absolute or relative urls are immaterial - as
long as the domain itself is the same.
>
Quote:
>Also if you are accessing session from included files the way they are
>called can lose the session. For instance if url includes are allowed
>and you do from a file with session_start() already called:
>include "/var/www/htdocs/file1.php";
>include "http://sameSite/file2.php";
>>
>the session will be available in file1 but not in file2
>>
>
True, if you do a url include. However - why would you ever do that on
your own site? It requires an additional call to the server and
additional server processing. It's much better to include it as a file
- in which case the session information is available.
>
Thanks to all for their repsponse. I will work on some code changes for
next couple of days based on your input.

Thanks,
Dave
Jerry Stuckle
Guest
 
Posts: n/a
#8: Jul 2 '08

re: Help with conflicting sessions


Johnny wrote:
Quote:
Jerry Stuckle wrote:
Quote:
>Dave wrote:
Quote:
>>Hopefully this is an easy question for those with more experience.
>>>
>>I have two separate programs that I want to use together on a website
>>>
>>Program A starts first and calls session_start().
>>>
>>Program B is started by the user clicking on a link and it also calls
>>session_start().
>>>
>>The session started by program B blows away the session started by
>>program A and program A will not work any longer.
>>>
>>How can I have two independent sessions that don't interfere with
>>each other?
>>>
>>Any advice or code snippets would be appreciated.
>>>
>>Thanks,
>>Dave
>>>
>>
>Dave,
>>
>Are you looking at the same domain? If so, they should have the same
>session. But that shouldn't be a problem - just store the variables
>you want in the apporpriate $_SESSION values (use arrays within the
>$_SESSION array to keep things cleaner).
>>
>If they are two different domains (remember - www.example.com and
>example.com are considered "different" by default), you should already
>have two sessions.
>>
>But without any code, it's hard to tell what you're doing. So it's
>even more difficult to see what's wrong.
>>
One thing to note is that sessions are lost when the url is not
relative, see here:
http://us.php.net/manual/en/session.idpassing.php
>
That's only if you're not using cookies. When using cookies (which
virtually everyone does), absolute or relative urls are immaterial - as
long as the domain itself is the same.
Quote:
Also if you are accessing session from included files the way they are
called can lose the session. For instance if url includes are allowed
and you do from a file with session_start() already called:
include "/var/www/htdocs/file1.php";
include "http://sameSite/file2.php";
>
the session will be available in file1 but not in file2
>
True, if you do a url include. However - why would you ever do that on
your own site? It requires an additional call to the server and
additional server processing. It's much better to include it as a file
- in which case the session information is available.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

the_mighty_snap_dragon@hotmail.com
Guest
 
Posts: n/a
#9: Jul 2 '08

re: Help with conflicting sessions


On Jul 2, 12:30*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
Johnny wrote:
Quote:
Jerry Stuckle wrote:
Quote:
Dave wrote:
>Hopefully this is an easy question for those with more experience.
>
Quote:
Quote:
>I have two separate programs that I want to use together on a website
>
Quote:
Quote:
>Program A starts first and calls session_start().
>
Quote:
Quote:
>Program B is started by the user clicking on a link and it also calls
>session_start().
>
Quote:
Quote:
>The session started by program B blows away the session started by
>program A and program A will not work any longer.
>
Quote:
Quote:
>How can I have two independent sessions that don't interfere with
>each other?
>
Quote:
Quote:
>Any advice or code snippets would be appreciated.
>
Quote:
Quote:
>Thanks,
>Dave
>
Quote:
Quote:
Dave,
>
Quote:
Quote:
Are you looking at the same domain? *If so, they should have the same
session. *But that shouldn't be a problem - just store the variables
you want in the apporpriate $_SESSION values (use arrays within the
$_SESSION array to keep things cleaner).
>
Quote:
Quote:
If they are two different domains (remember -www.example.comand
example.com are considered "different" by default), you should already
have two sessions.
>
Quote:
Quote:
But without any code, it's hard to tell what you're doing. *So it's
even more difficult to see what's wrong.
>
Quote:
One thing to note is that sessions are lost when the url is not
relative, see here:
http://us.php.net/manual/en/session.idpassing.php
>
That's only if you're not using cookies. *When using cookies (which
virtually everyone does), absolute or relative urls are immaterial - as
long as the domain itself is the same.
>
Quote:
Also if you are accessing session from included files the way they are
called can lose the session. For instance if url includes are allowed
and you do from a file with session_start() already called:
include "/var/www/htdocs/file1.php";
include "http://sameSite/file2.php";
>
Quote:
the session will be available in file1 but not in file2
>
True, if you do a url include. *However - why would you ever do that on
your own site? *It requires an additional call to the server and
additional server processing. *It's much better to include it as a file
- in which case the session information is available.
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
>
- Show quoted text -
You could just use session_name() to set two different sessions.

so like:
session_name("programA");
session_start(); /* your $_SESSION variable are now for programA */

and in your other 'program'

session_name("programB");
session_start(); /* your $_SESSION variables are now for programB */


Although, surely you can just use different variable names in one
session??
Closed Thread