Flash & PHP Session

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

    #1

    Flash & PHP Session

    Hi,

    I have an upload application written in PHP and Flash. The PHP page
    gets the file information via $_POST. Moreover, the user never
    actually visits the PHP page, rather Flash sends the information to the
    PHP page and then loads the result, all in the background. Right now,
    the php page cannot access the $_SESSION. Is there anyway that I can
    conitnue the PHP session when doing this or does the user have to visit
    the PHP page?

    Thanks.

    Steve

  • Jerry Stuckle

    #2
    Re: Flash & PHP Session

    Steve Cook wrote:
    Hi,
    >
    I have an upload application written in PHP and Flash. The PHP page
    gets the file information via $_POST. Moreover, the user never
    actually visits the PHP page, rather Flash sends the information to the
    PHP page and then loads the result, all in the background. Right now,
    the php page cannot access the $_SESSION. Is there anyway that I can
    conitnue the PHP session when doing this or does the user have to visit
    the PHP page?
    >
    Thanks.
    >
    Steve
    >
    Looks like your flash isn't sending the session cookie along with the
    rest of the request.

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

    Comment

    • Steve  Cook

      #3
      Re: Flash & PHP Session


      Jerry Stuckle wrote:
      Steve Cook wrote:
      Hi,

      I have an upload application written in PHP and Flash. The PHP page
      gets the file information via $_POST. Moreover, the user never
      actually visits the PHP page, rather Flash sends the information to the
      PHP page and then loads the result, all in the background. Right now,
      the php page cannot access the $_SESSION. Is there anyway that I can
      conitnue the PHP session when doing this or does the user have to visit
      the PHP page?

      Thanks.

      Steve
      >
      Looks like your flash isn't sending the session cookie along with the
      rest of the request.
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===
      Do you have an idea how I can get flash to send the session cookie?

      Comment

      • Jerry Stuckle

        #4
        Re: Flash & PHP Session

        Steve Cook wrote:
        Jerry Stuckle wrote:
        >
        >>Steve Cook wrote:
        >>
        >>>Hi,
        >>>
        >>>I have an upload application written in PHP and Flash. The PHP page
        >>>gets the file information via $_POST. Moreover, the user never
        >>>actually visits the PHP page, rather Flash sends the information to the
        >>>PHP page and then loads the result, all in the background. Right now,
        >>>the php page cannot access the $_SESSION. Is there anyway that I can
        >>>conitnue the PHP session when doing this or does the user have to visit
        >>>the PHP page?
        >>>
        >>>Thanks.
        >>>
        >>>Steve
        >>>
        >>
        >>Looks like your flash isn't sending the session cookie along with the
        >>rest of the request.
        >>
        >>--
        >>============= =====
        >>Remove the "x" from my email address
        >>Jerry Stuckle
        >>JDS Computer Training Corp.
        >>jstucklex@att global.net
        >>============= =====
        >
        >
        Do you have an idea how I can get flash to send the session cookie?
        >
        I think you're going to have to ask that in a Flash newsgroup. We're
        PHP programmers here.

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

        Comment

        • Steve  Cook

          #5
          Re: Flash & PHP Session


          Jerry Stuckle wrote:
          Steve Cook wrote:
          Jerry Stuckle wrote:
          >Steve Cook wrote:
          >
          >>Hi,
          >>
          >>I have an upload application written in PHP and Flash. The PHP page
          >>gets the file information via $_POST. Moreover, the user never
          >>actually visits the PHP page, rather Flash sends the information to the
          >>PHP page and then loads the result, all in the background. Right now,
          >>the php page cannot access the $_SESSION. Is there anyway that I can
          >>conitnue the PHP session when doing this or does the user have to visit
          >>the PHP page?
          >>
          >>Thanks.
          >>
          >>Steve
          >>
          >
          >Looks like your flash isn't sending the session cookie along with the
          >rest of the request.
          >
          >--
          >============== ====
          >Remove the "x" from my email address
          >Jerry Stuckle
          >JDS Computer Training Corp.
          >jstucklex@attg lobal.net
          >============== ====

          Do you have an idea how I can get flash to send the session cookie?
          >
          I think you're going to have to ask that in a Flash newsgroup. We're
          PHP programmers here.
          >
          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===
          I definitely know how to pass the session_id via flash. I guess I
          should have asked how do I manually set the session_id value in PHP?
          In other words how do I populate the session_id variable?

          Comment

          • Jerry Stuckle

            #6
            Re: Flash & PHP Session

            Steve Cook wrote:
            Jerry Stuckle wrote:
            >
            >>Steve Cook wrote:
            >>
            >>>Jerry Stuckle wrote:
            >>>
            >>>
            >>>>Steve Cook wrote:
            >>>>
            >>>>
            >>>>>Hi,
            >>>>>
            >>>>>I have an upload application written in PHP and Flash. The PHP page
            >>>>>gets the file information via $_POST. Moreover, the user never
            >>>>>actually visits the PHP page, rather Flash sends the information to the
            >>>>>PHP page and then loads the result, all in the background. Right now,
            >>>>>the php page cannot access the $_SESSION. Is there anyway that I can
            >>>>>conitnue the PHP session when doing this or does the user have to visit
            >>>>>the PHP page?
            >>>>>
            >>>>>Thanks.
            >>>>>
            >>>>>Steve
            >>>>>
            >>>>
            >>>>Looks like your flash isn't sending the session cookie along with the
            >>>>rest of the request.
            >>>>
            >>>>--
            >>>>=========== =======
            >>>>Remove the "x" from my email address
            >>>>Jerry Stuckle
            >>>>JDS Computer Training Corp.
            >>>>jstucklex@a ttglobal.net
            >>>>=========== =======
            >>>
            >>>
            >>>Do you have an idea how I can get flash to send the session cookie?
            >>>
            >>
            >>I think you're going to have to ask that in a Flash newsgroup. We're
            >>PHP programmers here.
            >>
            >>--
            >>============= =====
            >>Remove the "x" from my email address
            >>Jerry Stuckle
            >>JDS Computer Training Corp.
            >>jstucklex@att global.net
            >>============= =====
            >
            >
            I definitely know how to pass the session_id via flash. I guess I
            should have asked how do I manually set the session_id value in PHP?
            In other words how do I populate the session_id variable?
            >
            You don't. PHP does, based on the session id passed back by the browser
            - which is stored in a cookie.

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

            Comment

            • amygdala

              #7
              Re: Flash & PHP Session


              "Jerry Stuckle" <jstucklex@attg lobal.netschree f in bericht
              news:i8adnfdQ7q UVk3TZnZ2dnUVZ_ qOdnZ2d@comcast .com...
              Steve Cook wrote:
              >Jerry Stuckle wrote:
              >>
              >>>Steve Cook wrote:
              >>>
              >>>>Jerry Stuckle wrote:
              >>>>
              >>>>
              >>>>>Steve Cook wrote:
              >>>>>
              >>>>>
              >>>>>>Hi,
              >>>>>>
              >>>>>>I have an upload application written in PHP and Flash. The PHP page
              >>>>>>gets the file information via $_POST. Moreover, the user never
              >>>>>>actuall y visits the PHP page, rather Flash sends the information to
              >>>>>>the
              >>>>>>PHP page and then loads the result, all in the background. Right now,
              >>>>>>the php page cannot access the $_SESSION. Is there anyway that I can
              >>>>>>conitnu e the PHP session when doing this or does the user have to
              >>>>>>visit
              >>>>>>the PHP page?
              >>>>>>
              >>>>>>Thanks.
              >>>>>>
              >>>>>>Steve
              >>>>>>
              >>>>>
              >>>>>Looks like your flash isn't sending the session cookie along with the
              >>>>>rest of the request.
              >>>>>
              >>>>>--
              >>>>>========== ========
              >>>>>Remove the "x" from my email address
              >>>>>Jerry Stuckle
              >>>>>JDS Computer Training Corp.
              >>>>>jstucklex@ attglobal.net
              >>>>>========== ========
              >>>>
              >>>>
              >>>>Do you have an idea how I can get flash to send the session cookie?
              >>>>
              >>>
              >>>I think you're going to have to ask that in a Flash newsgroup. We're
              >>>PHP programmers here.
              >>>
              >>>--
              >>>============ ======
              >>>Remove the "x" from my email address
              >>>Jerry Stuckle
              >>>JDS Computer Training Corp.
              >>>jstucklex@at tglobal.net
              >>>============ ======
              >>
              >>
              >I definitely know how to pass the session_id via flash. I guess I
              >should have asked how do I manually set the session_id value in PHP?
              >In other words how do I populate the session_id variable?
              >>
              >
              You don't. PHP does, based on the session id passed back by the browser -
              which is stored in a cookie.
              >
              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===
              I beg to differ:

              Do something like:

              <?php
              ini_set('sessio n.use_cookies', '0');
              session_start() ;
              ?>

              Put your flash movie in the same page and echo the SID behind it (old school
              style):

              <object classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000"
              codebase="http://download.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=6,0,29,0"
              width="32" height="32">
              <param name="movie" value="whatever .swf?<?php echo SID ?>">
              <param name="quality" value="high">
              <embed src="whatever.s wf?<?php echo SID ?>" width="32" height="32"
              quality="high" pluginspage="ht tp://www.macromedia. com/go/getflashplayer"
              type="applicati on/x-shockwave-flash" sid=""></embed></object>

              This will give you access to the variable PHPSESSID in flash. Make sure you
              append this to every GET request to php.

              Notice though that appending session ID's to GET request are often
              considered a security risk. But since you are using flash and thus requests
              are made in the background (not through addressbar requests), it's somewhat
              safer to use IMO.

              Cheers


              Comment

              • amygdala

                #8
                Re: Flash &amp; PHP Session


                "amygdala" <noreply@norepl y.comschreef in bericht
                news:44e95b9a$0 $2013$9a622dc7@ news.kpnplanet. nl...
                >
                "Jerry Stuckle" <jstucklex@attg lobal.netschree f in bericht
                news:i8adnfdQ7q UVk3TZnZ2dnUVZ_ qOdnZ2d@comcast .com...
                >Steve Cook wrote:
                >>Jerry Stuckle wrote:
                >>>
                >>>>Steve Cook wrote:
                >>>>
                >>>>>Jerry Stuckle wrote:
                >>>>>
                >>>>>
                >>>>>>Steve Cook wrote:
                >>>>>>
                >>>>>>
                >>>>>>>Hi,
                >>>>>>>
                >>>>>>>I have an upload application written in PHP and Flash. The PHP page
                >>>>>>>gets the file information via $_POST. Moreover, the user never
                >>>>>>>actual ly visits the PHP page, rather Flash sends the information to
                >>>>>>>the
                >>>>>>>PHP page and then loads the result, all in the background. Right
                >>>>>>>now,
                >>>>>>>the php page cannot access the $_SESSION. Is there anyway that I can
                >>>>>>>conitn ue the PHP session when doing this or does the user have to
                >>>>>>>visit
                >>>>>>>the PHP page?
                >>>>>>>
                >>>>>>>Thanks .
                >>>>>>>
                >>>>>>>Steve
                >>>>>>>
                >>>>>>
                >>>>>>Looks like your flash isn't sending the session cookie along with the
                >>>>>>rest of the request.
                >>>>>>
                >>>>>>--
                >>>>>>========= =========
                >>>>>>Remove the "x" from my email address
                >>>>>>Jerry Stuckle
                >>>>>>JDS Computer Training Corp.
                >>>>>>jstucklex @attglobal.net
                >>>>>>========= =========
                >>>>>
                >>>>>
                >>>>>Do you have an idea how I can get flash to send the session cookie?
                >>>>>
                >>>>
                >>>>I think you're going to have to ask that in a Flash newsgroup. We're
                >>>>PHP programmers here.
                >>>>
                >>>>--
                >>>>=========== =======
                >>>>Remove the "x" from my email address
                >>>>Jerry Stuckle
                >>>>JDS Computer Training Corp.
                >>>>jstucklex@a ttglobal.net
                >>>>=========== =======
                >>>
                >>>
                >>I definitely know how to pass the session_id via flash. I guess I
                >>should have asked how do I manually set the session_id value in PHP?
                >>In other words how do I populate the session_id variable?
                >>>
                >>
                >You don't. PHP does, based on the session id passed back by the
                >browser - which is stored in a cookie.
                >>
                >--
                >============== ====
                >Remove the "x" from my email address
                >Jerry Stuckle
                >JDS Computer Training Corp.
                >jstucklex@attgl obal.net
                >============== ====
                >
                I beg to differ:
                >
                Do something like:
                >
                <?php
                ini_set('sessio n.use_cookies', '0');
                session_start() ;
                ?>
                >
                Put your flash movie in the same page and echo the SID behind it (old
                school style):
                >
                <object classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000"
                codebase="http://download.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=6,0,29,0"
                width="32" height="32">
                <param name="movie" value="whatever .swf?<?php echo SID ?>">
                <param name="quality" value="high">
                <embed src="whatever.s wf?<?php echo SID ?>" width="32" height="32"
                quality="high" pluginspage="ht tp://www.macromedia. com/go/getflashplayer"
                type="applicati on/x-shockwave-flash" sid=""></embed></object>
                >
                This will give you access to the variable PHPSESSID in flash. Make sure
                you append this to every GET request to php.
                >
                Notice though that appending session ID's to GET request are often
                considered a security risk. But since you are using flash and thus
                requests are made in the background (not through addressbar requests),
                it's somewhat safer to use IMO.
                >
                Cheers
                >
                Ooops I didn't thoroughly read the whole thread. I didn't read that a
                session was already started.

                Forget about the ini_set('sessio n.use_cookies', '0'); part.

                And do (untested):

                <object classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000"
                codebase="http://download.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=6,0,29,0"
                width="32" height="32">
                <param name="movie" value="whatever .swf?PHPSESSID= <?php echo session_id()
                ?>">
                <param name="quality" value="high">
                <embed src="whatever.s wf?PHPSESSID=<? php echo session_id() ?>" width="32"
                height="32" quality="high"
                pluginspage="ht tp://www.macromedia. com/go/getflashplayer"
                type="applicati on/x-shockwave-flash" sid=""></embed></object>

                Then in the php page that handles flash requests:

                <?php
                session_id($_GE T['PHPSESSID']);
                session_start() ;
                ?>

                Should do the trick. But maybe I'm overlooking something here.


                Comment

                • amygdala

                  #9
                  Re: Flash &amp; PHP Session


                  "amygdala" <noreply@norepl y.comschreef in bericht
                  news:44e96003$0 $2030$9a622dc7@ news.kpnplanet. nl...
                  >
                  "amygdala" <noreply@norepl y.comschreef in bericht
                  news:44e95b9a$0 $2013$9a622dc7@ news.kpnplanet. nl...
                  >>
                  >"Jerry Stuckle" <jstucklex@attg lobal.netschree f in bericht
                  >news:i8adnfdQ7 qUVk3TZnZ2dnUVZ _qOdnZ2d@comcas t.com...
                  >>Steve Cook wrote:
                  >>>Jerry Stuckle wrote:
                  >>>>
                  >>>>>Steve Cook wrote:
                  >>>>>
                  >>>>>>Jerry Stuckle wrote:
                  >>>>>>
                  >>>>>>
                  >>>>>>>Steve Cook wrote:
                  >>>>>>>
                  >>>>>>>
                  >>>>>>>>Hi,
                  >>>>>>>>
                  >>>>>>>>I have an upload application written in PHP and Flash. The PHP page
                  >>>>>>>>gets the file information via $_POST. Moreover, the user never
                  >>>>>>>>actuall y visits the PHP page, rather Flash sends the information to
                  >>>>>>>>the
                  >>>>>>>>PHP page and then loads the result, all in the background. Right
                  >>>>>>>>now,
                  >>>>>>>>the php page cannot access the $_SESSION. Is there anyway that I
                  >>>>>>>>can
                  >>>>>>>>conitnu e the PHP session when doing this or does the user have to
                  >>>>>>>>visit
                  >>>>>>>>the PHP page?
                  >>>>>>>>
                  >>>>>>>>Thank s.
                  >>>>>>>>
                  >>>>>>>>Steve
                  >>>>>>>>
                  >>>>>>>
                  >>>>>>>Looks like your flash isn't sending the session cookie along with the
                  >>>>>>>rest of the request.
                  >>>>>>>
                  >>>>>>>--
                  >>>>>>>======== ==========
                  >>>>>>>Remove the "x" from my email address
                  >>>>>>>Jerry Stuckle
                  >>>>>>>JDS Computer Training Corp.
                  >>>>>>>jstuckle x@attglobal.net
                  >>>>>>>======== ==========
                  >>>>>>
                  >>>>>>
                  >>>>>>Do you have an idea how I can get flash to send the session cookie?
                  >>>>>>
                  >>>>>
                  >>>>>I think you're going to have to ask that in a Flash newsgroup. We're
                  >>>>>PHP programmers here.
                  >>>>>
                  >>>>>--
                  >>>>>========== ========
                  >>>>>Remove the "x" from my email address
                  >>>>>Jerry Stuckle
                  >>>>>JDS Computer Training Corp.
                  >>>>>jstucklex@ attglobal.net
                  >>>>>========== ========
                  >>>>
                  >>>>
                  >>>I definitely know how to pass the session_id via flash. I guess I
                  >>>should have asked how do I manually set the session_id value in PHP?
                  >>>In other words how do I populate the session_id variable?
                  >>>>
                  >>>
                  >>You don't. PHP does, based on the session id passed back by the
                  >>browser - which is stored in a cookie.
                  >>>
                  >>--
                  >>============= =====
                  >>Remove the "x" from my email address
                  >>Jerry Stuckle
                  >>JDS Computer Training Corp.
                  >>jstucklex@attgl obal.net
                  >>============= =====
                  >>
                  >I beg to differ:
                  >>
                  >Do something like:
                  >>
                  ><?php
                  >ini_set('sessi on.use_cookies' , '0');
                  >session_start( );
                  >?>
                  >>
                  >Put your flash movie in the same page and echo the SID behind it (old
                  >school style):
                  >>
                  ><object classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000"
                  >codebase="http ://download.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=6,0,29,0"
                  >width="32" height="32">
                  > <param name="movie" value="whatever .swf?<?php echo SID ?>">
                  > <param name="quality" value="high">
                  > <embed src="whatever.s wf?<?php echo SID ?>" width="32" height="32"
                  >quality="hig h" pluginspage="ht tp://www.macromedia. com/go/getflashplayer"
                  >type="applicat ion/x-shockwave-flash" sid=""></embed></object>
                  >>
                  >This will give you access to the variable PHPSESSID in flash. Make sure
                  >you append this to every GET request to php.
                  >>
                  >Notice though that appending session ID's to GET request are often
                  >considered a security risk. But since you are using flash and thus
                  >requests are made in the background (not through addressbar requests),
                  >it's somewhat safer to use IMO.
                  >>
                  >Cheers
                  >>
                  >
                  Ooops I didn't thoroughly read the whole thread. I didn't read that a
                  session was already started.
                  >
                  Forget about the ini_set('sessio n.use_cookies', '0'); part.
                  >
                  And do (untested):
                  >
                  <object classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000"
                  codebase="http://download.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=6,0,29,0"
                  width="32" height="32">
                  <param name="movie" value="whatever .swf?PHPSESSID= <?php echo session_id()
                  ?>">
                  <param name="quality" value="high">
                  <embed src="whatever.s wf?PHPSESSID=<? php echo session_id() ?>" width="32"
                  height="32" quality="high"
                  pluginspage="ht tp://www.macromedia. com/go/getflashplayer"
                  type="applicati on/x-shockwave-flash" sid=""></embed></object>
                  >
                  Then in the php page that handles flash requests:
                  >
                  <?php
                  session_id($_GE T['PHPSESSID']);
                  session_start() ;
                  ?>
                  >
                  Should do the trick. But maybe I'm overlooking something here.
                  And once again, I didn't read thoroughly anough:
                  >This will give you access to the variable PHPSESSID in flash. Make sure
                  >you append this to every GET request to php.
                  Should of course be: POST variable to php

                  And then in the php page that handles flash requests:

                  <?php
                  session_id($_PO ST['PHPSESSID']); // instead of $_GET[...]
                  session_start() ;
                  ?>

                  lol


                  Comment

                  • amygdala

                    #10
                    Re: Flash &amp; PHP Session

                    <snip>
                    >>>>>Is there anyway that I can
                    >>>>>conitnue the PHP session when doing this or does the user have to visit
                    >>>>>the PHP page?
                    <snip>

                    So basically; what I'm trying to say here is: Yes, you need flash embedded
                    in _a_ (not _the_) php script (within the same domain of course) to read the
                    cookie, and Jerry was right. ;)

                    As a last resort to ommitting flash put in a php file, you could use
                    javascript to read the cookie and append the PHPSESSID var. But you would
                    have to rely on the user having javascript turned on. Which is a rather big
                    no no.

                    Also, I've been out of webdeveloping for a while, so I'm not sure whether
                    this is still allowed by the majority of browsers anyway.

                    HTH


                    Comment

                    • Steve  Cook

                      #11
                      Re: Flash &amp; PHP Session

                      amygdala wrote:
                      <snip>
                      >
                      >>>>Is there anyway that I can
                      >>>>conitnue the PHP session when doing this or does the user have to visit
                      >>>>the PHP page?
                      >
                      <snip>
                      >
                      So basically; what I'm trying to say here is: Yes, you need flash embedded
                      in _a_ (not _the_) php script (within the same domain of course) to read the
                      cookie, and Jerry was right. ;)
                      >
                      As a last resort to ommitting flash put in a php file, you could use
                      javascript to read the cookie and append the PHPSESSID var. But you would
                      have to rely on the user having javascript turned on. Which is a rather big
                      no no.
                      >
                      Also, I've been out of webdeveloping for a while, so I'm not sure whether
                      this is still allowed by the majority of browsers anyway.
                      >
                      HTH
                      Thanks for all of your help. I ended up adding the following to the
                      php page to continue the session and accept the session_id from Flash:

                      Code:
                      <?
                      if (!session_id()) {
                      if (isset($_GET['session_id'])) {
                      session_id($_GET['session_id]);
                      }
                      session_start();
                      }
                      ?>
                      Thanks again.

                      Steve

                      Comment

                      Working...