Help with conflicting sessions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    #1

    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
  • AnrDaemon

    #2
    Re: Help with conflicting sessions

    Greetings, Dave.
    In reply to Your message dated Tuesday, July 1, 2008, 23:53:10,
    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
    What you calling "programs" at first?
    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.
    Can you please illustrate it in more presentable way?
    I can't understand, how it is possible.
    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.
    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@free mail.ru>

    Comment

    • Dave

      #3
      Re: Help with conflicting sessions

      AnrDaemon <anrdaemon@free mail.ruwrote in
      news:373384186. 20080702003356@ freemail.ru:
      Greetings, Dave.
      In reply to Your message dated Tuesday, July 1, 2008, 23:53:10,
      >
      >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
      >
      What you calling "programs" at first?
      >
      >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.
      >
      Can you please illustrate it in more presentable way?
      I can't understand, how it is possible.
      >
      >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.
      >
      >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

      Comment

      • Jerry Stuckle

        #4
        Re: Help with conflicting sessions

        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
        >
        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@attgl obal.net
        =============== ===

        Comment

        • Johnny

          #5
          Re: Help with conflicting sessions

          Jerry Stuckle wrote:
          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
          >>
          >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:


          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

          Comment

          • Jerry Stuckle

            #6
            Re: Help with conflicting sessions

            Johnny wrote:
            Jerry Stuckle wrote:
            >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
            >>>
            >>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:

            >
            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.
            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@attgl obal.net
            =============== ===

            Comment

            • Dave

              #7
              Re: Help with conflicting sessions

              Jerry Stuckle <jstucklex@attg lobal.netwrote in news:g4fneo$dc$ 1
              @registered.mot zarella.org:
              Johnny wrote:
              >Jerry Stuckle wrote:
              >>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
              >>>>
              >>>Program A starts first and calls session_start() .
              >>>>
              >>>Program B is started by the user clicking on a link and it also
              calls
              >>>session_star t().
              >>>>
              >>>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.
              >
              >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

              Comment

              • Jerry Stuckle

                #8
                Re: Help with conflicting sessions

                Johnny wrote:
                Jerry Stuckle wrote:
                >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
                >>>
                >>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:

                >
                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.
                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@attgl obal.net
                =============== ===

                Comment

                • the_mighty_snap_dragon@hotmail.com

                  #9
                  Re: Help with conflicting sessions

                  On Jul 2, 12:30 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                  Johnny wrote:
                  Jerry Stuckle wrote:
                  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
                  >
                  >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.
                  >
                  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.
                  jstuck...@attgl obal.net
                  =============== ===- Hide quoted text -
                  >
                  - Show quoted text -
                  You could just use session_name() to set two different sessions.

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

                  and in your other 'program'

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


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

                  Comment

                  Working...