By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

Variable persistance between scripts

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Kasper K" <ka****@kau.dk> wrote in message
news:14**************************@posting.google.c om...
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


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:
http://www.affiliatewindow.com/affil...ls.php?mid=611
http://www.affiliatewindow.com/a.pl?590

Jul 17 '05 #2

P: n/a
On 16 Dec 2003 06:51:54 -0800, ka****@kau.dk (Kasper K) wrote:
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.


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/
Jul 17 '05 #3

P: n/a
Kasper K wrote:
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.


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).

Jul 17 '05 #4

P: n/a
*** Kasper K wrote/escribió (16 Dec 2003 06:51:54 -0800):
Can you have truly global variables that persist between scripts?
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.
I want the variables to reside in memory and not in i.e. sessions,
cookies, external file, database, post and get.


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
--
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.