Variable persistance between scripts

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

    #1

    Variable persistance between scripts

    Hi,

    I'm using PHP with apache.

    From what I understand, global variables are only global to one php
    script (i.e. the file and all the files it includes), but they are not
    persisted between HTTP calls.

    Can you have truly global variables that persist between scripts?

    I want the variables to reside in memory and not in i.e. sessions,
    cookies, external file, database, post and get.

    Thanks

    Kasper, Denmark
  • Richard Grove

    #2
    Re: Variable persistance between scripts

    "Kasper K" <kasper@kau.d k> wrote in message
    news:14e91d16.0 312160651.3fe88 c12@posting.goo gle.com...[color=blue]
    > Hi,
    >
    > I'm using PHP with apache.
    >
    > From what I understand, global variables are only global to one php
    > script (i.e. the file and all the files it includes), but they are not
    > persisted between HTTP calls.
    >
    > Can you have truly global variables that persist between scripts?
    >
    > I want the variables to reside in memory and not in i.e. sessions,
    > cookies, external file, database, post and get.
    >
    > Thanks
    >
    > Kasper, Denmark[/color]

    There is not another way and why would you want there to be?

    Regards
    Richard Grove

    http://shopbuilder.org - ecommerce systems
    Become a Shop Builder re-seller:
    Affiliate marketing is a simple way to earn money online, using our affiliate platform. Join a global community of publishers and advertisers.

    Affiliate marketing is a simple way to earn money online, using our affiliate platform. Join a global community of publishers and advertisers.






    Comment

    • David Mackenzie

      #3
      Re: Variable persistance between scripts

      On 16 Dec 2003 06:51:54 -0800, kasper@kau.dk (Kasper K) wrote:
      [color=blue]
      >Hi,
      >
      >I'm using PHP with apache.
      >
      >From what I understand, global variables are only global to one php
      >script (i.e. the file and all the files it includes), but they are not
      >persisted between HTTP calls.
      >
      >Can you have truly global variables that persist between scripts?
      >
      >I want the variables to reside in memory and not in i.e. sessions,
      >cookies, external file, database, post and get.[/color]

      The only way to identify a user across requests is to pass a session
      id via POST or GET, or to store it in a cookie.

      Sorry, but that's the way it is.

      It's not a limitation of PHP, but of HTTP.

      --
      David ( @priz.co.uk )
      The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
      The Tarbrax Chronicle: http://www.tarbraxchronicle.com/

      Comment

      • Kevin Thorpe

        #4
        Re: Variable persistance between scripts

        Kasper K wrote:[color=blue]
        > Hi,
        >
        > I'm using PHP with apache.
        >
        > From what I understand, global variables are only global to one php
        > script (i.e. the file and all the files it includes), but they are not
        > persisted between HTTP calls.
        >
        > Can you have truly global variables that persist between scripts?
        >
        > I want the variables to reside in memory and not in i.e. sessions,
        > cookies, external file, database, post and get.[/color]

        The use of session variables is transparent. They are serialised and
        restored between php script executions for you. If you really must have
        variables in memory then there is an mm module to use shared memory to
        store session vars (*nix only). The only benefit of this though is
        performance (at the expense of memory).



        Comment

        • Alvaro G Vicario

          #5
          Re: Variable persistance between scripts

          *** Kasper K wrote/escribió (16 Dec 2003 06:51:54 -0800):[color=blue]
          > Can you have truly global variables that persist between scripts?[/color]

          Nope, apart from cookies, sesssions, get and post. There's a good reason:
          without previous systems, there is not way to know what HTTP request belong
          to the same logical application and same user session.
          [color=blue]
          > I want the variables to reside in memory and not in i.e. sessions,
          > cookies, external file, database, post and get.[/color]

          You probably need a custom webserver for that (that's, for instance, what
          webmin uses). It's unlikely it's worth the effort.

          --
          --
          -- Álvaro G. Vicario - Burgos, Spain
          --

          Comment

          Working...