running scripts without session

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

    running scripts without session

    When I run my scripts on a http server I can use the
    $_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have my
    local file system laid out exactly as the one on my server.

    The issue is that when I run the script without using session_start I have
    to set the document root manually. Now every time I switch from running
    locally to a web server I have to comment out the line. Its not a big deal
    but I'm wonder if I could somehow tell php to use a default document root if
    a session isn't started?

    Thanks,
    Jon


  • zono

    #2
    Re: running scripts without session


    Jon Slaughter :
    When I run my scripts on a http server I can use the
    $_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have my
    local file system laid out exactly as the one on my server.
    >
    The issue is that when I run the script without using session_start I have
    to set the document root manually. Now every time I switch from running
    locally to a web server I have to comment out the line. Its not a big deal
    but I'm wonder if I could somehow tell php to use a default document root if
    a session isn't started?
    >
    Thanks,
    Jon
    <?php
    /**
    * May be something like this ?
    * When function session_start()
    * is not called or not successed
    * $_SESSION is not set.
    */

    $docRoot = isset($_SESSION ) ? $_SESSION['Document_Root'] :
    $_SERVER['DOCUMENT_ROOT'];
    ?>

    Comment

    • Jon Slaughter

      #3
      Re: running scripts without session


      "zono" <gonaumov@gmail .comwrote in message
      news:1182064637 .077781.99180@c 77g2000hse.goog legroups.com...
      >
      Jon Slaughter :
      >When I run my scripts on a http server I can use the
      >$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
      >my
      >local file system laid out exactly as the one on my server.
      >>
      >The issue is that when I run the script without using session_start I
      >have
      >to set the document root manually. Now every time I switch from running
      >locally to a web server I have to comment out the line. Its not a big
      >deal
      >but I'm wonder if I could somehow tell php to use a default document root
      >if
      >a session isn't started?
      >>
      >Thanks,
      >Jon
      <?php
      /**
      * May be something like this ?
      * When function session_start()
      * is not called or not successed
      * $_SESSION is not set.
      */
      >
      $docRoot = isset($_SESSION ) ? $_SESSION['Document_Root'] :
      $_SERVER['DOCUMENT_ROOT'];
      ?>
      >
      lol
      duh... can't believe I didn't think about that ;/

      Thanks,
      Jon


      Comment

      • Jon Slaughter

        #4
        Re: running scripts without session


        "zono" <gonaumov@gmail .comwrote in message
        news:1182064637 .077781.99180@c 77g2000hse.goog legroups.com...
        >
        Jon Slaughter :
        >When I run my scripts on a http server I can use the
        >$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
        >my
        >local file system laid out exactly as the one on my server.
        >>
        >The issue is that when I run the script without using session_start I
        >have
        >to set the document root manually. Now every time I switch from running
        >locally to a web server I have to comment out the line. Its not a big
        >deal
        >but I'm wonder if I could somehow tell php to use a default document root
        >if
        >a session isn't started?
        >>
        >Thanks,
        >Jon
        <?php
        /**
        * May be something like this ?
        * When function session_start()
        * is not called or not successed
        * $_SESSION is not set.
        */
        >
        $docRoot = isset($_SESSION ) ? $_SESSION['Document_Root'] :
        $_SERVER['DOCUMENT_ROOT'];
        ?>
        >
        hmm, actually it doesn't work. because I use session_start() ; I get a
        document root... just not the correct one. I guess I have to find some
        setting to change in the local http server the debugger uses.

        Thanks,
        Jon


        Comment

        • Jon Slaughter

          #5
          Re: running scripts without session


          "Jon Slaughter" <Jon_Slaughter@ Hotmail.comwrot e in message
          news:t13di.4440 $bP5.2625@newss vr19.news.prodi gy.net...
          When I run my scripts on a http server I can use the
          $_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
          my local file system laid out exactly as the one on my server.
          >
          The issue is that when I run the script without using session_start I have
          to set the document root manually. Now every time I switch from running
          locally to a web server I have to comment out the line. Its not a big deal
          but I'm wonder if I could somehow tell php to use a default document root
          if a session isn't started?
          >
          Thanks,
          Jon
          >
          ok, nm... was a setting in the server config.



          Comment

          • Georgi Naumov

            #6
            Re: running scripts without session


            Jon Slaughter :
            "Jon Slaughter" <Jon_Slaughter@ Hotmail.comwrot e in message
            news:t13di.4440 $bP5.2625@newss vr19.news.prodi gy.net...
            When I run my scripts on a http server I can use the
            $_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
            my local file system laid out exactly as the one on my server.

            The issue is that when I run the script without using session_start I have
            to set the document root manually. Now every time I switch from running
            locally to a web server I have to comment out the line. Its not a big deal
            but I'm wonder if I could somehow tell php to use a default document root
            if a session isn't started?

            Thanks,
            Jon
            >
            ok, nm... was a setting in the server config.
            Hm.
            Did you see value of $_SERVER['DOCUMENT_ROOT'] ?
            May be it can help you.

            Comment

            • ZeldorBlat

              #7
              Re: running scripts without session

              On Jun 17, 3:41 am, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
              "zono" <gonau...@gmail .comwrote in message
              >
              news:1182064637 .077781.99180@c 77g2000hse.goog legroups.com...
              >
              >
              >
              >
              >
              Jon Slaughter :
              When I run my scripts on a http server I can use the
              $_SESSION['Document_Root'] to get the dir of the scripts and stuff(I have
              my
              local file system laid out exactly as the one on my server.
              >
              The issue is that when I run the script without using session_start I
              have
              to set the document root manually. Now every time I switch from running
              locally to a web server I have to comment out the line. Its not a big
              deal
              but I'm wonder if I could somehow tell php to use a default document root
              if
              a session isn't started?
              >
              Thanks,
              Jon
              <?php
              /**
              * May be something like this ?
              * When function session_start()
              * is not called or not successed
              * $_SESSION is not set.
              */
              >
              $docRoot = isset($_SESSION ) ? $_SESSION['Document_Root'] :
              $_SERVER['DOCUMENT_ROOT'];
              ?>
              >
              lol
              duh... can't believe I didn't think about that ;/
              >
              Thanks,
              Jon
              Why wouldn't you just /always/ use $_SERVER['DOCUMENT_ROOT'] ?

              Comment

              • Jon Slaughter

                #8
                Re: running scripts without session


                "ZeldorBlat " <zeldorblat@gma il.comwrote in message
                news:1182094277 .182685.134020@ p77g2000hsh.goo glegroups.com.. .
                On Jun 17, 3:41 am, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
                >"zono" <gonau...@gmail .comwrote in message
                >>
                >news:118206463 7.077781.99180@ c77g2000hse.goo glegroups.com.. .
                >>
                >>
                >>
                >>
                >>
                Jon Slaughter :
                >When I run my scripts on a http server I can use the
                >$_SESSION['Document_Root'] to get the dir of the scripts and stuff(I
                >have
                >my
                >local file system laid out exactly as the one on my server.
                >>
                >The issue is that when I run the script without using session_start I
                >have
                >to set the document root manually. Now every time I switch from
                >running
                >locally to a web server I have to comment out the line. Its not a big
                >deal
                >but I'm wonder if I could somehow tell php to use a default document
                >root
                >if
                >a session isn't started?
                >>
                >Thanks,
                >Jon
                <?php
                /**
                * May be something like this ?
                * When function session_start()
                * is not called or not successed
                * $_SESSION is not set.
                */
                >>
                $docRoot = isset($_SESSION ) ? $_SESSION['Document_Root'] :
                $_SERVER['DOCUMENT_ROOT'];
                ?>
                >>
                >lol
                >duh... can't believe I didn't think about that ;/
                >>
                >Thanks,
                >Jon
                >
                Why wouldn't you just /always/ use $_SERVER['DOCUMENT_ROOT'] ?
                >
                You should I guess. I didn't see that it was getting set locally for some
                reason and didn't realize that it was pointing to the wrong place. Was just
                being stupid ;/



                Comment

                Working...