Jump to content

How do I get global persistent variables in PHP


HuntsvilleMan

Recommended Posts

I need help getting global persistence variables in a set of php programs that interact like the ones shown below:

 

                          |------ -----|

                          \ /              |

      Start.php --->Callback.php----> message.php -->

            |                    / \     

          \ /                    | 

    Remote vendor service---|

 

    At present I pass all parameters to startcall.php and it in turn it passes the values as URL parameters to other programs.  The problem I have is that the remote vendor request I make truncates long URLs before they come back.  They tell me it has something to do with the way URLs get encoded (a chunking issue) and they can’t fix it. 

 

To shorten up the URLs  I need to find a way to make all parameters I send to start.php  become persistent for about 3 minutes and be avaiable to all PHP programs.  Session variables don’t seem to be quite what I need so far as I understand.  For example, they would be fine to let start.php remember but then the other programs don’t have the values needed. 

 

So far the only solution I know of would be for start.php to store all values in a database table and then have the other programs recall the data as needed. 

 

Is there a simpler way to get the kind of global persistent variables I need in this php application?

 

Thanks

Link to comment
Share on other sites

Variables are in RAM memory while a script is running on your local server. They will become unaccessible as soon as your script stops running (IE. the http request was fulfilled) and they are never accessible by remote servers.

 

If the issue is passing information on to another vendor, how does their API work exactly? You could provide the information to them via XML, that's what XML is intended for. Alternatively, if XML is not an option due to their API, you might consider building a POST request to send to them.

Link to comment
Share on other sites

You need to use a form of external storage to make data persistent.

 

Store the data in a flat file or database with an expire time you can check. You probably also want some form of garbage collector that checks for expired entries at intervals.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.