Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 1st, 2008, 09:05 PM
Dave
Guest
 
Posts: n/a
Default Help with conflicting sessions

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
  #2  
Old July 1st, 2008, 09:35 PM
AnrDaemon
Guest
 
Posts: n/a
Default 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>

  #3  
Old July 2nd, 2008, 12:25 AM
Dave
Guest
 
Posts: n/a
Default 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
  #4  
Old July 2nd, 2008, 03:15 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================

  #5  
Old July 2nd, 2008, 06:35 AM
Johnny
Guest
 
Posts: n/a
Default 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
  #6  
Old July 2nd, 2008, 12:15 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================

  #7  
Old July 2nd, 2008, 12:25 PM
Dave
Guest
 
Posts: n/a
Default 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
  #8  
Old July 2nd, 2008, 12:35 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================

  #9  
Old July 2nd, 2008, 07:45 PM
the_mighty_snap_dragon@hotmail.com
Guest
 
Posts: n/a
Default 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??
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles