Must set and immediately get $_SESSION variable - help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • comp.lang.php

    #1

    Must set and immediately get $_SESSION variable - help!

    This is an urgent request (as always)

    Code:
    generate_admin_customer_position_dropdown($customerResult,
    $customerResult[0]->id);
    print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
    This code will generate an HTML dropdown as well as set a $_SESSION
    variable.

    I can verify the function works perfectly and in fact sets the session
    variable every time. Problem is that I need to set and then
    IMMEDIATELY get the session variable w/o redirection because
    redirection is undoable at the portion of the PHP code that this must
    work in.

    What do I do? Each time I try this the session variable is NOT
    immediately available until a latter iteration renders it available but
    far too late to be used.

    How do I set and then IMMEDIATELY get a SESSION variable? This is an
    urgent request!!

    Thanx
    Phil

  • Jerry Stuckle

    #2
    Re: Must set and immediately get $_SESSION variable - help!

    comp.lang.php wrote:[color=blue]
    > This is an urgent request (as always)
    >
    >
    Code:
    >
    > 	 generate_admin_customer_position_dropdown($customerResult,
    > $customerResult[0]->id);
    > 	 print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
    >
    >
    > This code will generate an HTML dropdown as well as set a $_SESSION
    > variable.
    >
    > I can verify the function works perfectly and in fact sets the session
    > variable every time. Problem is that I need to set and then
    > IMMEDIATELY get the session variable w/o redirection because
    > redirection is undoable at the portion of the PHP code that this must
    > work in.
    >
    > What do I do? Each time I try this the session variable is NOT
    > immediately available until a latter iteration renders it available but
    > far too late to be used.
    >
    > How do I set and then IMMEDIATELY get a SESSION variable? This is an
    > urgent request!!
    >
    > Thanx
    > Phil
    >[/color]

    Maybe just store it in a work variable? Why does it HAVE to come from
    the $_SESSION variable?

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

    Comment

    • Norman Peelman

      #3
      Re: Must set and immediately get $_SESSION variable - help!

      "comp.lang. php" <phillip.s.powe ll@gmail.com> wrote in message
      news:1140923087 .282743.321640@ v46g2000cwv.goo glegroups.com.. .[color=blue]
      > This is an urgent request (as always)
      >
      >
      Code:
      >
      > generate_admin_customer_position_dropdown($customerResult,
      > $customerResult[0]->id);
      > print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
      >
      >
      > This code will generate an HTML dropdown as well as set a $_SESSION
      > variable.
      >
      > I can verify the function works perfectly and in fact sets the session
      > variable every time. Problem is that I need to set and then
      > IMMEDIATELY get the session variable w/o redirection because
      > redirection is undoable at the portion of the PHP code that this must
      > work in.
      >
      > What do I do? Each time I try this the session variable is NOT
      > immediately available until a latter iteration renders it available but
      > far too late to be used.
      >
      > How do I set and then IMMEDIATELY get a SESSION variable? This is an
      > urgent request!!
      >
      > Thanx
      > Phil
      >[/color]

      Not exactly sure what you mean... How can you verify that the $_SESSION
      variable is set if you also state you can't access it.

      place this before your print_r statement: echo "<!-- SESSION
      status:\n\r".va r_dump($_SESSIO N)."\n\r-->";

      then look in the source code of the resulting page. This will show you all
      the $_SESSION variables and their values.

      I can set a session and immediatley access it all day long... it has to be
      something else. To me it appears that this could be the culprit:

      print_r($_SESSI ON["${projectAcron ym}_customerSOW ObjectArray"]);

      ....what is "${projectAcron ym}_customerSOW ObjectArray"? In otherwords what
      is 'projectAcronym '? It can do it this way too, no problem. If
      'projectAcronym ' is a variable (it really has a $ in front of it) then you
      need to make sure it is set properly. The $ can go inside the curly braces
      as well and should keep things easier to read. Just try entering the little
      code snippet above and you'll see what the session variables are.

      Norm




      Comment

      • comp.lang.php

        #4
        Re: Must set and immediately get $_SESSION variable - help!


        Jerry Stuckle wrote:[color=blue]
        > comp.lang.php wrote:[color=green]
        > > This is an urgent request (as always)
        > >
        > >
        Code:
        > >
        > > 	 generate_admin_customer_position_dropdown($customerResult,
        > > $customerResult[0]->id);
        > > 	 print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
        > >
        > >
        > > This code will generate an HTML dropdown as well as set a $_SESSION
        > > variable.
        > >
        > > I can verify the function works perfectly and in fact sets the session
        > > variable every time. Problem is that I need to set and then
        > > IMMEDIATELY get the session variable w/o redirection because
        > > redirection is undoable at the portion of the PHP code that this must
        > > work in.
        > >
        > > What do I do? Each time I try this the session variable is NOT
        > > immediately available until a latter iteration renders it available but
        > > far too late to be used.
        > >
        > > How do I set and then IMMEDIATELY get a SESSION variable? This is an
        > > urgent request!!
        > >
        > > Thanx
        > > Phil
        > >[/color]
        >
        > Maybe just store it in a work variable? Why does it HAVE to come from
        > the $_SESSION variable?
        >[/color]

        The function returns an HTML string variable, I don't know of any other
        way in PHP to store it for latter (but immediate) retrieval other than
        via $_SESSION.

        Else, please explain "work variable" to me.

        Phil
        [color=blue]
        > --
        > =============== ===
        > Remove the "x" from my email address
        > Jerry Stuckle
        > JDS Computer Training Corp.
        > jstucklex@attgl obal.net
        > =============== ===[/color]

        Comment

        • comp.lang.php

          #5
          Re: Must set and immediately get $_SESSION variable - help!


          Norman Peelman wrote:[color=blue]
          > "comp.lang. php" <phillip.s.powe ll@gmail.com> wrote in message
          > news:1140923087 .282743.321640@ v46g2000cwv.goo glegroups.com.. .[color=green]
          > > This is an urgent request (as always)
          > >
          > >
          Code:
          > >
          > > generate_admin_customer_position_dropdown($customerResult,
          > > $customerResult[0]->id);
          > > print_r($_SESSION["${projectAcronym}_customerSOWObjectArray"]);
          > >
          > >
          > > This code will generate an HTML dropdown as well as set a $_SESSION
          > > variable.
          > >
          > > I can verify the function works perfectly and in fact sets the session
          > > variable every time. Problem is that I need to set and then
          > > IMMEDIATELY get the session variable w/o redirection because
          > > redirection is undoable at the portion of the PHP code that this must
          > > work in.
          > >
          > > What do I do? Each time I try this the session variable is NOT
          > > immediately available until a latter iteration renders it available but
          > > far too late to be used.
          > >
          > > How do I set and then IMMEDIATELY get a SESSION variable? This is an
          > > urgent request!!
          > >
          > > Thanx
          > > Phil
          > >[/color]
          >
          > Not exactly sure what you mean... How can you verify that the $_SESSION
          > variable is set if you also state you can't access it.
          >
          > place this before your print_r statement: echo "<!-- SESSION
          > status:\n\r".va r_dump($_SESSIO N)."\n\r-->";
          >
          > then look in the source code of the resulting page. This will show you all
          > the $_SESSION variables and their values.
          >
          > I can set a session and immediatley access it all day long... it has to be
          > something else. To me it appears that this could be the culprit:
          >
          > print_r($_SESSI ON["${projectAcron ym}_customerSOW ObjectArray"]);
          >
          > ...what is "${projectAcron ym}_customerSOW ObjectArray"? In otherwords what
          > is 'projectAcronym '? It can do it this way too, no problem. If
          > 'projectAcronym ' is a variable (it really has a $ in front of it) then you
          > need to make sure it is set properly. The $ can go inside the curly braces
          > as well and should keep things easier to read. Just try entering the little
          > code snippet above and you'll see what the session variables are.
          >[/color]

          Thanks, however, over the weekend I was able to brute-force it to work
          by rewriting the entire function. To not dump out a 100-line function
          to solve you all the heartache of dealing with mounds of raw code,
          basically, it works now, sets and gets $_SESSION variable as it should,
          so thanx!

          Phil
          [color=blue]
          > Norm[/color]

          Comment

          Working...