Application Scope variables ?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Application Scope variables ?

    I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
    Is there a similar mechanism in PHP?

    aa Guest

  2. Similar Questions and Discussions

    1. Global Variables and scope
      Ok, I'm creating a fairly large RIA using many components set on a page. They all share a common list. It is a Project list that is displayed in a...
    2. Initialize Server Scope Variables
      We have a mix of ColdFusion servers running in a production or development mode. Some applications we have developed will send e-mails when running...
    3. DB Field name="application" and Application scope variables
      Hi, There is DB Field application which overwrited ,as I see , Application scope variable Are there way to solve this problem without using...
    4. Application Scope
      I have a farm of CF5 servers. In order to reduce the number of times I hit the database, I'm saving data within the application scope. I'm setting...
    5. Local Scope Variables
      Hi, I'm having a bit of trouble with using some local scope variables. I have a function where I want to define a variable, then use that...
  3. #2

    Default Re: Application Scope variables ?

    aa wrote:
    > I am migrating to PHP from ASP where there are the Application Scope
    > variables which are accessible from any page on a website and which are
    > used, in particular, for hit counters.
    > Is there a similar mechanism in PHP?
    Hi,

    Yes there is, take a look at sessions:
    [url]http://nl3.php.net/manual/en/ref.session.php[/url]

    Regards,
    Ruben.
    Ruben van Engelenburg Guest

  4. #3

    Default Re: Application Scope variables ?

    "Ruben van Engelenburg" <ruben@NOSPAM!.nl> wrote in message
    news:414ebb56$0$65124$e4fe514c@news.xs4all.nl...
    > aa wrote:
    > > I am migrating to PHP from ASP where there are the Application Scope
    > > variables which are accessible from any page on a website and which are
    > > used, in particular, for hit counters.
    > > Is there a similar mechanism in PHP?
    >
    > Hi,
    >
    > Yes there is, take a look at sessions:
    > [url]http://nl3.php.net/manual/en/ref.session.php[/url]
    Sessions are not the same as application scope, I don't believe.

    I've seen references to shared memory schemes, but they are avaialble to the
    entire computer, not just a single application (all sessions running under
    the same site id, for example).

    - Virgil


    Virgil Green Guest

  5. #4

    Default Re: Application Scope variables ?

    Dear Virgil,

    your thinking is still too influenced by the rigid ASP structure.
    Relax, open your mind and RTFM on sessions. :-)


    Best Regards,

    Lucas

    "Virgil Green" <vjg@DESPAMobsydian.com> wrote in message news:<CnE3d.12658$yp2.5590@newssvr30.news.prodigy. com>...
    > "Ruben van Engelenburg" <ruben@NOSPAM!.nl> wrote in message
    > news:414ebb56$0$65124$e4fe514c@news.xs4all.nl...
    > > aa wrote:
    > > > I am migrating to PHP from ASP where there are the Application Scope
    > > > variables which are accessible from any page on a website and which are
    > > > used, in particular, for hit counters.
    > > > Is there a similar mechanism in PHP?
    > >
    > > Hi,
    > >
    > > Yes there is, take a look at sessions:
    > > [url]http://nl3.php.net/manual/en/ref.session.php[/url]
    >
    > Sessions are not the same as application scope, I don't believe.
    >
    > I've seen references to shared memory schemes, but they are avaialble to the
    > entire computer, not just a single application (all sessions running under
    > the same site id, for example).
    >
    > - Virgil
    Lucas Guest

  6. #5

    Default Re: Application Scope variables ?

    > your thinking is still too influenced by the rigid ASP structure.
    > Relax, open your mind and RTFM on sessions. :-)
    Session variables are not the same as application-level variables. ASP
    offers an application framework, ASP *is* the framework.

    Having said that, you can replicate functionality via PHP by either using
    common files for variable storage/retrieval, or using a database. Some info
    should be easily locatable by searching.
    Zurab Davitiani Guest

  7. #6

    Default Re: Application Scope variables ?

    Dear Zurab,

    sessions are stored as common files on the web server, one can
    configure it accordingly to his/her needs so that data(variables) are
    accesible from the required scope. Is there anything I missed?


    Best Regards,

    Lucas


    Zurab Davitiani <agt@mindless.com> wrote in message news:<ALJ3d.21759$Lf5.2677@newssvr27.news.prodigy. com>...
    > > your thinking is still too influenced by the rigid ASP structure.
    > > Relax, open your mind and RTFM on sessions. :-)
    >
    > Session variables are not the same as application-level variables. ASP
    > offers an application framework, ASP *is* the framework.
    >
    > Having said that, you can replicate functionality via PHP by either using
    > common files for variable storage/retrieval, or using a database. Some info
    > should be easily locatable by searching.
    Lucas Guest

  8. #7

    Default Re: Application Scope variables ?

    "Lucas" <thelucas@directbox.com> wrote in message
    news:fdb66b30.0409201432.a250159@posting.google.co m...
    > Dear Virgil,
    >
    > your thinking is still too influenced by the rigid ASP structure.
    > Relax, open your mind and RTFM on sessions. :-)
    I'm hardly influenced by ASP structure. I've never worked in ASP. I've read
    the PHP manual sections on sessions many times before.

    Please, enlighten me. Explain to me how sessions could be used to provide
    the equivalent of application-scoped variables in ASP. The closest thing I
    see is by sharing session IDs. That, of course, is a hack. There would be
    nothing by default to synchronize access between multiple requests, so each
    request could start with the same session info, update it and then spend
    time merrily writing over each others changes. I could write my own custom
    save handler, but I believe that writing such a handler to manage multiple
    sessions as a single "session" would violate the spirit of the session and
    lead to a maintenance nightmare.

    I look forward to the details of your strategy.

    - Virgil


    Virgil Green Guest

  9. #8

    Default Re: Application Scope variables ?

    Session will only make such a variable available within this session.
    But I am talking about a variable available from any page from any session

    "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message
    news:cip0pa$ig4$1$8300dec7@news.demon.co.uk...
    >
    > "aa" <aa@virgin.net> wrote in message
    > news:415002f7$0$42212$ed2e19e4@ptn-nntp-reader04.plus.net...
    > > Thanks.
    > > You mean that PHP does not allow to store application-level variables in
    > > memory and every time I need to modify such a variable I have to
    retrieve
    > > it
    > > from disc (a file or DB) and then to write it back?
    >
    > If you want to store variables between one page and another the PHP way is
    > sessions. All you need is session_start() at the beginning of each script.
    > This will create an empty $_SESSION array the first time, then give you
    back
    > everything you put in it.
    >
    > Note that you do not have to write the session data out to file manually
    as
    > PHP will do it automatically for you at the end of the script. It's all in
    > the manual.
    >
    > --
    > Tony Marston
    >
    > [url]http://www.tonymarston.net[/url]
    >
    >
    >
    > > "Zurab Davitiani" <agt@mindless.com> wrote in message
    > > news:ALJ3d.21759$Lf5.2677@newssvr27.news.prodigy.c om...
    > >> > your thinking is still too influenced by the rigid ASP structure.
    > >> > Relax, open your mind and RTFM on sessions. :-)
    > >>
    > >> Session variables are not the same as application-level variables. ASP
    > >> offers an application framework, ASP *is* the framework.
    > >>
    > >> Having said that, you can replicate functionality via PHP by either
    using
    > >> common files for variable storage/retrieval, or using a database. Some
    > > info
    > >> should be easily locatable by searching.
    > >
    > >
    >
    >

    aa Guest

  10. #9

    Default Re: Application Scope variables ?

    "sessions are stored as common files on the web server"

    Lucas,

    1. Do these "common files" keep sitting on the disk after the relevant
    session expired?
    2. If they do, then for how long?
    3. And how they might be accessed from another session?
    Even if they can be accessable, I have difficulties to see a practical use
    of them unless you keep track of every session file which is a tedious task



    "Lucas" <thelucas@directbox.com> wrote in message
    news:fdb66b30.0409202352.6263ac6f@posting.google.c om...
    > Dear Zurab,
    >
    > sessions are stored as common files on the web server, one can
    > configure it accordingly to his/her needs so that data(variables) are
    > accesible from the required scope. Is there anything I missed?
    >
    >
    > Best Regards,
    >
    > Lucas
    >
    >
    > Zurab Davitiani <agt@mindless.com> wrote in message
    news:<ALJ3d.21759$Lf5.2677@newssvr27.news.prodigy. com>...
    > > > your thinking is still too influenced by the rigid ASP structure.
    > > > Relax, open your mind and RTFM on sessions. :-)
    > >
    > > Session variables are not the same as application-level variables. ASP
    > > offers an application framework, ASP *is* the framework.
    > >
    > > Having said that, you can replicate functionality via PHP by either
    using
    > > common files for variable storage/retrieval, or using a database. Some
    info
    > > should be easily locatable by searching.

    aa Guest

  11. #10

    Default Re: Application Scope variables ?

    Just to stream the discussion up - how a page hit conter in implemented in PHP?
    In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
    This variable is sitting in the memory as long as the Application (i.e. the website) is running.
    If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.

    How do I get the same effect in PHP?
    "aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
    I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
    Is there a similar mechanism in PHP?

    aa Guest

  12. #11

    Default Re: Application Scope variables ?


    "aa" <aa@virgin.net> wrote in message
    news:41505762$0$42260$ed2e19e4@ptn-nntp-reader04.plus.net...
    > "sessions are stored as common files on the web server"
    >
    > Lucas,
    >
    > 1. Do these "common files" keep sitting on the disk after the relevant
    > session expired?
    > 2. If they do, then for how long?
    > 3. And how they might be accessed from another session?
    > Even if they can be accessable, I have difficulties to see a practical use
    > of them unless you keep track of every session file which is a tedious
    task

    1. The Session management part of PHP cleans them up regularly.
    2. Depends upon your settings in php.ini.
    3. By using the same session ID for multiple "sessions"

    And I find it highly impractical to attempt to use them constructively in
    this manner. Better to understand this part of sessions to allow you to be
    more careful when it comes to securing them. If one doesn't have cookies
    enabled, one merely needs to put the appropriate variable=value in your URL
    to hijaack a session.

    - Virgil


    Virgil Green Guest

  13. #12

    Default Re: Application Scope variables ?


    "aa" <aa@virgin.net> wrote in message
    news:415055cf$0$42237$ed2e19e4@ptn-nntp-reader04.plus.net...
    > Session will only make such a variable available within this session.
    > But I am talking about a variable available from any page from any session
    Then do what other people have already suggested:
    (a) Store those variables in a database.
    (b) Use a configuration which you can include() in every script.

    There are no application-level variables in PHP which persist across pages
    and sessions, so get used to it.

    --
    Tony Marston

    [url]http://www.tonymarston.net[/url]


    > "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message
    > news:cip0pa$ig4$1$8300dec7@news.demon.co.uk...
    >>
    >> "aa" <aa@virgin.net> wrote in message
    >> news:415002f7$0$42212$ed2e19e4@ptn-nntp-reader04.plus.net...
    >> > Thanks.
    >> > You mean that PHP does not allow to store application-level variables
    >> > in
    >> > memory and every time I need to modify such a variable I have to
    > retrieve
    >> > it
    >> > from disc (a file or DB) and then to write it back?
    >>
    >> If you want to store variables between one page and another the PHP way
    >> is
    >> sessions. All you need is session_start() at the beginning of each
    >> script.
    >> This will create an empty $_SESSION array the first time, then give you
    > back
    >> everything you put in it.
    >>
    >> Note that you do not have to write the session data out to file manually
    > as
    >> PHP will do it automatically for you at the end of the script. It's all
    >> in
    >> the manual.
    >>
    >> --
    >> Tony Marston
    >>
    >> [url]http://www.tonymarston.net[/url]
    >>
    >>
    >>
    >> > "Zurab Davitiani" <agt@mindless.com> wrote in message
    >> > news:ALJ3d.21759$Lf5.2677@newssvr27.news.prodigy.c om...
    >> >> > your thinking is still too influenced by the rigid ASP structure.
    >> >> > Relax, open your mind and RTFM on sessions. :-)
    >> >>
    >> >> Session variables are not the same as application-level variables. ASP
    >> >> offers an application framework, ASP *is* the framework.
    >> >>
    >> >> Having said that, you can replicate functionality via PHP by either
    > using
    >> >> common files for variable storage/retrieval, or using a database. Some
    >> > info
    >> >> should be easily locatable by searching.
    >> >
    >> >
    >>
    >>
    >
    >

    Tony Marston Guest

  14. #13

    Default Re: Application Scope variables ?


    "Virgil Green" <vjg@DESPAMobsydian.com> wrote in message
    news:ifV3d.162$q67.47@newssvr11.news.prodigy.com.. .
    > "Lucas" <thelucas@directbox.com> wrote in message
    > news:fdb66b30.0409201432.a250159@posting.google.co m...
    >> Dear Virgil,
    >>
    >> your thinking is still too influenced by the rigid ASP structure.
    >> Relax, open your mind and RTFM on sessions. :-)
    >
    > I'm hardly influenced by ASP structure. I've never worked in ASP. I've
    > read
    > the PHP manual sections on sessions many times before.
    >
    > Please, enlighten me. Explain to me how sessions could be used to provide
    > the equivalent of application-scoped variables in ASP.
    Store these variables in a database, or in a configuration file which you
    can include() in every script.

    PHP does not have any equivalent to application-scoped variables in ASP.

    --
    Tony Marston

    [url]http://www.tonymarston.net[/url]


    > The closest thing I
    > see is by sharing session IDs. That, of course, is a hack. There would be
    > nothing by default to synchronize access between multiple requests, so
    > each
    > request could start with the same session info, update it and then spend
    > time merrily writing over each others changes. I could write my own custom
    > save handler, but I believe that writing such a handler to manage multiple
    > sessions as a single "session" would violate the spirit of the session and
    > lead to a maintenance nightmare.
    >
    > I look forward to the details of your strategy.
    >
    > - Virgil
    >
    >

    Tony Marston Guest

  15. #14

    Default Re: Application Scope variables ?

    To implement a hit counter in PHP I would use a database table.

    There is no such thing as being able to detect when the application is closed. The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser? That is impossible to tell.

    --
    Tony Marston

    [url]http://www.tonymarston.net[/url]


    "aa" <aa@virgin.net> wrote in message news:415058ee$0$42257$ed2e19e4@ptn-nntp-reader04.plus.net...
    Just to stream the discussion up - how a page hit conter in implemented in PHP?
    In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
    This variable is sitting in the memory as long as the Application (i.e. the website) is running.
    If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.

    How do I get the same effect in PHP?
    "aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
    I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
    Is there a similar mechanism in PHP?

    Tony Marston Guest

  16. #15

    Default Re: Application Scope variables ?

    >Just to stream the discussion up - how a page hit conter in implemented in PHP?

    I'd use a database:
    UPDATE hit_count set count=count+1, last=now() where url='...';
    or if I really wanted details for each hit, add an entry to a hit_log table,
    logging time, URL, and perhaps other stuff like IP, user name, session, referrer, etc.
    >In ASP you increment a relative Application scope variable every time a page is
    >requested. This veraible is accessible from any session.
    Besides hit counters, of what *USE* is such a variable?
    It can be accessed from (and messed up by) so many different
    concurrent sessions that any significant read/write use will have
    to worry about locking issues. Does ASP even guarantee that several
    sessions each doing the equivalent of $hitcount++; will be atomic
    and not lose counts (on a multiprocessor machine, possibly)?

    Assume $last_server is the ID of the last waitperson assigned to a table (and
    it's one of those "Application-scope" variables.
    IDs run from 1 to $max_server. You want to assign them in turn, round-robin.

    $last_server++;
    if ($last_server > $max_server) { $last_server = 1; }
    $this_server = $last_server;
    .... assign $this_server to serve the food for this order ...

    Now, how do you write that (or its equivalent in ASP) so it's
    multi-session, multi-processor safe? You don't assign the same
    server two orders a row. You don't skip anyone. Not even if a bunch
    of orders come in simultaneously.


    I also wouldn't be too pleased to learn that I'd lose several days
    worth of changes to that variable (kept only in memory) if the
    machine crashed. In particular, losing a variable like 'next invoice
    number to assign' kept in memory only would be a real nuisance.
    >This variable is sitting in the memory as long as the Application (i.e. the website) is
    >running.
    Which means you can lose it at any time if the Application is running.
    >If the Application is stopped, it fires an event "application_on_close" and on this
    >event you write an application data to a file from which it can be recovered when the
    >application is restarted.
    And if the application, or system, crashes? How often do you actually intentionally
    shut down a web server (besides applying security patches)? In my experience, this
    is MUCH less often than CPU fan failure or power supply failure.
    >How do I get the same effect in PHP?
    What do you need it for? I think it makes an unreliable hit counter and it's not
    good for much else.

    Gordon L. Burditt
    Gordon Burditt Guest

  17. #16

    Default Re: Application Scope variables ?

    >To implement a hit counter in PHP I would use a database table.

    Agreed.
    >There is no such thing as being able to detect when the application is closed. The
    >client simply stops sending requests to your web site. Is he still reading the last
    >page? Has he jumped to another site? Has he closed the browser? That is impossible to
    >tell.
    That's a SESSION, not the application. And no, you can't tell when
    it's closed except by timeout or occasionally by someone clicking
    on "LOG OUT".

    The APPLICATION being referred to is the web server itself. Shutting
    it down might be done with commands like "apachectl stop" or
    "shutdown", or tripping over the power cord. In my experience when
    the web server is shut down, it is shut down quite rudely by CPU
    fan failure, more than 50% of the time.

    Gordon L. Burditt

    Gordon Burditt Guest

  18. #17

    Default Re: Application Scope variables ?

    "Does ASP even guarantee that several sessions each doing the equivalent of
    $hitcount++; "

    ASP' application is an object with a method "lock" to handle attempts to
    change a variable from two or more sessions at a time. I do not know is it
    guaranties something, but it works.
    So if there is nothing like that in PHP - thanks - you saved me time lokinmg
    for something which is not there.


    "Gordon Burditt" <gordonb.a6hin@burditt.org> wrote in message
    news:cipte4$qal@library2.airnews.net...
    > >Just to stream the discussion up - how a page hit conter in implemented
    in PHP?
    >
    > I'd use a database:
    > UPDATE hit_count set count=count+1, last=now() where url='...';
    > or if I really wanted details for each hit, add an entry to a hit_log
    table,
    > logging time, URL, and perhaps other stuff like IP, user name, session,
    referrer, etc.
    >
    > >In ASP you increment a relative Application scope variable every time a
    page is
    > >requested. This veraible is accessible from any session.
    >
    > Besides hit counters, of what *USE* is such a variable?
    > It can be accessed from (and messed up by) so many different
    > concurrent sessions that any significant read/write use will have
    > to worry about locking issues. Does ASP even guarantee that several
    > sessions each doing the equivalent of $hitcount++; will be atomic
    > and not lose counts (on a multiprocessor machine, possibly)?
    >
    > Assume $last_server is the ID of the last waitperson assigned to a table
    (and
    > it's one of those "Application-scope" variables.
    > IDs run from 1 to $max_server. You want to assign them in turn,
    round-robin.
    >
    > $last_server++;
    > if ($last_server > $max_server) { $last_server = 1; }
    > $this_server = $last_server;
    > ... assign $this_server to serve the food for this order ...
    >
    > Now, how do you write that (or its equivalent in ASP) so it's
    > multi-session, multi-processor safe? You don't assign the same
    > server two orders a row. You don't skip anyone. Not even if a bunch
    > of orders come in simultaneously.
    >
    >
    > I also wouldn't be too pleased to learn that I'd lose several days
    > worth of changes to that variable (kept only in memory) if the
    > machine crashed. In particular, losing a variable like 'next invoice
    > number to assign' kept in memory only would be a real nuisance.
    >
    > >This variable is sitting in the memory as long as the Application (i.e.
    the website) is
    > >running.
    >
    > Which means you can lose it at any time if the Application is running.
    >
    > >If the Application is stopped, it fires an event "application_on_close"
    and on this
    > >event you write an application data to a file from which it can be
    recovered when the
    > >application is restarted.
    >
    > And if the application, or system, crashes? How often do you actually
    intentionally
    > shut down a web server (besides applying security patches)? In my
    experience, this
    > is MUCH less often than CPU fan failure or power supply failure.
    >
    > >How do I get the same effect in PHP?
    >
    > What do you need it for? I think it makes an unreliable hit counter and
    it's not
    > good for much else.
    >
    > Gordon L. Burditt

    aa Guest

  19. #18

    Default Re: Application Scope variables ?

    > Then do what other people have already suggested:

    Actually I have suggested that myself, but hoped that there is more elegant
    solution
    Thanks.

    "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message
    news:cips55$sjm$1$8300dec7@news.demon.co.uk...
    >
    > "aa" <aa@virgin.net> wrote in message
    > news:415055cf$0$42237$ed2e19e4@ptn-nntp-reader04.plus.net...
    > > Session will only make such a variable available within this session.
    > > But I am talking about a variable available from any page from any
    session
    >
    > Then do what other people have already suggested:
    > (a) Store those variables in a database.
    > (b) Use a configuration which you can include() in every script.
    >
    > There are no application-level variables in PHP which persist across pages
    > and sessions, so get used to it.
    >
    > --
    > Tony Marston
    >
    > [url]http://www.tonymarston.net[/url]
    >
    >
    >
    > > "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message
    > > news:cip0pa$ig4$1$8300dec7@news.demon.co.uk...
    > >>
    > >> "aa" <aa@virgin.net> wrote in message
    > >> news:415002f7$0$42212$ed2e19e4@ptn-nntp-reader04.plus.net...
    > >> > Thanks.
    > >> > You mean that PHP does not allow to store application-level variables
    > >> > in
    > >> > memory and every time I need to modify such a variable I have to
    > > retrieve
    > >> > it
    > >> > from disc (a file or DB) and then to write it back?
    > >>
    > >> If you want to store variables between one page and another the PHP way
    > >> is
    > >> sessions. All you need is session_start() at the beginning of each
    > >> script.
    > >> This will create an empty $_SESSION array the first time, then give you
    > > back
    > >> everything you put in it.
    > >>
    > >> Note that you do not have to write the session data out to file
    manually
    > > as
    > >> PHP will do it automatically for you at the end of the script. It's all
    > >> in
    > >> the manual.
    > >>
    > >> --
    > >> Tony Marston
    > >>
    > >> [url]http://www.tonymarston.net[/url]
    > >>
    > >>
    > >>
    > >> > "Zurab Davitiani" <agt@mindless.com> wrote in message
    > >> > news:ALJ3d.21759$Lf5.2677@newssvr27.news.prodigy.c om...
    > >> >> > your thinking is still too influenced by the rigid ASP structure.
    > >> >> > Relax, open your mind and RTFM on sessions. :-)
    > >> >>
    > >> >> Session variables are not the same as application-level variables.
    ASP
    > >> >> offers an application framework, ASP *is* the framework.
    > >> >>
    > >> >> Having said that, you can replicate functionality via PHP by either
    > > using
    > >> >> common files for variable storage/retrieval, or using a database.
    Some
    > >> > info
    > >> >> should be easily locatable by searching.
    > >> >
    > >> >
    > >>
    > >>
    > >
    > >
    >
    >

    aa Guest

  20. #19

    Default Re: Application Scope variables ?

    "There is no such thing as being able to detect when the application is closed.The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser?
    That is impossible to tell."

    That is not necessary to tell, for the actions of a particular visitor are not relevant.
    As it happens with Windows/IIS/ASP, Application can either be closed manually, or it times out if there are not requests for a preset period of time. In other words, application closes when the last active session times out.
    Is this the case with Apache server?
    "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:cipsgh$npr$1$8302bc10@news.demon.co.uk...
    To implement a hit counter in PHP I would use a database table.

    There is no such thing as being able to detect when the application is closed. The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser? That is impossible to tell.

    --
    Tony Marston

    [url]http://www.tonymarston.net[/url]


    "aa" <aa@virgin.net> wrote in message news:415058ee$0$42257$ed2e19e4@ptn-nntp-reader04.plus.net...
    Just to stream the discussion up - how a page hit conter in implemented in PHP?
    In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
    This variable is sitting in the memory as long as the Application (i.e. the website) is running.
    If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.

    How do I get the same effect in PHP?
    "aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
    I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
    Is there a similar mechanism in PHP?

    aa Guest

  21. #20

    Default Re: Application Scope variables ?

    If by "application" you mean "web server" then it is not common practice to stop the web server when the last client has finished. A web server usually runs 24/7 so that it is available whenever somebody wants to access it. If you are talking about a closed application such as on a company's intranet which may only be available during certain times of day then shutting down the web server does nothing more than shut down the web server. There is no concept of running any closedown routines for whatever application may have been accessed during the time the web server was running. A web server like Apache is merely a vehicle for servicing HTTP requests. It serves up html documents or php documents or whatever. Those documents are the application. It has no knowledge of any particular application which it may run. Why should it?

    --
    Tony Marston

    [url]http://www.tonymarston.net[/url]


    "aa" <aa@virgin.net> wrote in message news:41508cf8$0$17960$ed2619ec@ptn-nntp-reader02.plus.net...
    "There is no such thing as being able to detect when the application is closed.The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser?
    That is impossible to tell."

    That is not necessary to tell, for the actions of a particular visitor are not relevant.
    As it happens with Windows/IIS/ASP, Application can either be closed manually, or it times out if there are not requests for a preset period of time. In other words, application closes when the last active session times out.
    Is this the case with Apache server?
    "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:cipsgh$npr$1$8302bc10@news.demon.co.uk...
    To implement a hit counter in PHP I would use a database table.

    There is no such thing as being able to detect when the application is closed. The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser? That is impossible to tell.

    --
    Tony Marston

    [url]http://www.tonymarston.net[/url]


    "aa" <aa@virgin.net> wrote in message news:415058ee$0$42257$ed2e19e4@ptn-nntp-reader04.plus.net...
    Just to stream the discussion up - how a page hit conter in implemented in PHP?
    In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
    This variable is sitting in the memory as long as the Application (i.e. the website) is running.
    If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.

    How do I get the same effect in PHP?
    "aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
    I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
    Is there a similar mechanism in PHP?

    Tony Marston Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139