473,394 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
Jul 17 '05 #1
4 3657
"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
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
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
*** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris S. | last post by:
I'm trying to write programs that make use of a lot of dynamic structures. To aid in debugging and data extraction, I'd like to persist these objects in a form that's readable, but one that also...
2
by: Leo | last post by:
Hi, I'm back to ASP for a short while and I was wondering how I could save the entire Application/Session-state to a file or database and how to read it back afterwards. I'd like to preserve...
0
by: Michael.McD | last post by:
Is there any consensus on the way to go when implementing object persistance to a dB? For example MHibernate v. DataObjects (x-tensive). Cheers, Michael McD
11
by: Paul D.Smith | last post by:
Can Python create a variable "on-the-fly". For example I would like something like... make_variable('OSCAR', 'the grouch'); print OSCAR; ....to output... the grouch
10
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in...
5
by: Andy G | last post by:
I have a registration page that captures 75% of the users data. After they enter that info they are redirected to one of two pages depending on how they answered a question on the registation...
45
by: bigdadro | last post by:
I've created a new class using prototype.js. After I make the ajax.request all references to this.myClassMethodorVariable are lost. Does the ajax method blow out the object persistance? I'm fairly...
6
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why doesn't the global variable "divId" always refer to the element with id="divId"?...
16
by: John | last post by:
Does the length of my C variable names have any affect, performance-wise, on my final executable program? I mean, once compiled, etc., is there any difference between these two: number = 3; n =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.