Jump to content

Share a variable between two php files on two different servers.


Proqrammer

Recommended Posts

You could create an include file with serialized data and set some restriction logic that allows each server access. Now I said serialized because it allows you to use a simple function like $vars = unserialize ( file_get_contents ( 'http://www.site.com/file.php' ) );. But if you need more control, you can use [b]include()[/b], but all of these remote calls need URL fopen wrappers to be turned on.


You could also pass the variable as part of the URL.

file1.php:
[code]
echo '<a heref="www.server2.com/file2.php?var1=' . $var1 . '&var2=' . $var2 .'>Link to other server<' . '/a' . >'; 
[/code]

file2.php
[code]
echo "Var 1:  " .  $_GET['var1'];
echo "Var 2:  " .  $_GET['var2'];
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.