problem with session variables

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

    problem with session variables

    Elsewhere on a form page I am declaring a variable

    *************** *************** *
    session_start() ;
    $_SESSION['testvar'] = "sometext";

    At the top of the page that will process the form code I have this line.

    session_start() ;
    $testppp=$_SESS ION['testvar'];

    echo $testppp;

    *************** *************** *

    But nothing is echoed. What am I missing?


    Garry Jones
    Sweden


  • iulian.ilea

    #2
    Re: problem with session variables

    If you use PHP on Windows you have to define session.save_pa th in case
    you use sessions stored as files. Check this:


    Let me know it this was the problem.

    Garry Jones wrote:
    Elsewhere on a form page I am declaring a variable
    >
    *************** *************** *
    session_start() ;
    $_SESSION['testvar'] = "sometext";
    >
    At the top of the page that will process the form code I have this line.
    >
    session_start() ;
    $testppp=$_SESS ION['testvar'];
    >
    echo $testppp;
    >
    *************** *************** *
    >
    But nothing is echoed. What am I missing?
    >
    >
    Garry Jones
    Sweden

    Comment

    • Garry Jones

      #3
      Re: problem with session variables

      iulian.ilea" <iulian.ilea@gm ail.comskrev i meddelandet
      news:1160422033 .181958.171090@ i3g2000cwc.goog legroups.com...
      If you use PHP on Windows you have to define session.save_pa th in case
      you use sessions stored as files. Check this:

      >
      Let me know it this was the problem.
      No, thats not the problem!

      :(

      Garry


      Comment

      • Jerry Stuckle

        #4
        Re: problem with session variables

        Garry Jones wrote:
        Elsewhere on a form page I am declaring a variable
        >
        *************** *************** *
        session_start() ;
        $_SESSION['testvar'] = "sometext";
        >
        At the top of the page that will process the form code I have this line.
        >
        session_start() ;
        $testppp=$_SESS ION['testvar'];
        >
        echo $testppp;
        >
        *************** *************** *
        >
        But nothing is echoed. What am I missing?
        >
        >
        Garry Jones
        Sweden
        >
        >
        Are you calling session_start() before ANY output is sent to the
        browser? This includes html, php output or even white space.

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

        Comment

        • Garry Jones

          #5
          Re: problem with session variables

          "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
          news:tbSdnViJDI v6LbfYnZ2dnUVZ_ oudnZ2d@comcast .com...
          Are you calling session_start() before ANY output is sent to the browser?
          This includes html, php output or even white space.
          No. Are you supposed to?

          I can session_start in similar code on other sites and they work ok.

          My php session start is in a segment of code called in by a ´condition"
          being met)

          This problem is persisting. I need to carry a variable forward past a form
          being read in and processed,

          Garry Jones
          Sweden


          Comment

          • Garry Jones

            #6
            Re: problem with session variables

            "Garry Jones" <garry.jones@mo rack.seskrev i meddelandet
            news:eged1e$s38 $1@yggdrasil.gl ocalnet.net...
            This problem is persisting.
            More code

            form code
            session_start() ;
            $_SESSION['testvar'] = "sometext";
            echo $_SESSION['testvar'];

            At the top of the page that will process the form code I have this line.
            session_start() ;
            echo $_SESSION['testvar'];

            The first "echo $_SESSION['testvar']" works
            The second one does not so the session varible is reset to null. But WHY?

            Garry Jones
            Sweden


            Comment

            • Pedro Graca

              #7
              Re: problem with session variables

              Garry Jones wrote:
              "Garry Jones" <garry.jones@mo rack.seskrev i meddelandet
              news:eged1e$s38 $1@yggdrasil.gl ocalnet.net...
              > This problem is persisting.
              [...]
              At the top of the page that will process the form code I have this line.
              session_start() ;
              echo $_SESSION['testvar'];
              Try this in the page that will process the form code

              if (!headers_sent( )) {
              session_start() ;
              echo $_SESSION['testvar']
              } else {
              echo 'Cannot start session. Headers have already been sent.';
              }

              Then, if it complains with "Cannot start session. ..." move the lines up
              in the source code until it stops complaining.


              Links:



              --
              File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

              Comment

              • Jerry Stuckle

                #8
                Re: problem with session variables

                Garry Jones wrote:
                "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                news:tbSdnViJDI v6LbfYnZ2dnUVZ_ oudnZ2d@comcast .com...
                >
                >
                >>Are you calling session_start() before ANY output is sent to the browser?
                >>This includes html, php output or even white space.
                >
                >
                No. Are you supposed to?
                >
                I can session_start in similar code on other sites and they work ok.
                >
                My php session start is in a segment of code called in by a ´condition"
                being met)
                >
                This problem is persisting. I need to carry a variable forward past a form
                being read in and processed,
                >
                Garry Jones
                Sweden
                >
                >
                Yes. Try adding this code just before you call session_start() and
                you'll see your error:

                ini_set('displa y_errors', 1);
                error_reporting (E_ALL & ~E_NOTICE);

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

                Comment

                • .:[ ikciu ]:.

                  #9
                  Re: problem with session variables

                  Hmm Garry Jones <garry.jones@mo rack.sewrote:
                  But nothing is echoed. What am I missing?
                  sessions_start( ) must be the first command before you use any output
                  function

                  --
                  ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
                  Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

                  2be || !2be $this =mysql_query();


                  Comment

                  • Garry Jones

                    #10
                    Re: problem with session variables

                    "Jerry Stuckle" <jstucklex@attg lobal.netskrev i meddelandet
                    news:PcOdnYjogo 3UYrfYnZ2dnUVZ_ q2dnZ2d@comcast .com...
                    Yes. Try adding this code just before you call session_start() and
                    you'll see your error:
                    The problem was that my web hotel had this function disabled. I was able to
                    go in and change the setting and now it works.

                    Thanks for all your replies.

                    Garry Jones
                    Sweden



                    Comment

                    Working...