FLEB <so*********@mm ers.and.evil.on es.will.bow-down-to.us> wrote in message news:<1l******* *************** *******@40tude. net>...
Regarding this well-known quote, often attributed to John's famous "20 Dec
2003 10:54:38 -0800" speech:
I would like to pass array variables between URLs but I don't know
how. I know its possible with sessions, but sessions can become
useless if cookies are disabled. I have unsuccessfully tried using
post and get methods.
Thank you
John
Here is a little trick I use (I know, some people may not like it) but
scripting with duct tape can be fun! Note: this does not work across
site wide, unless you work it into all your links and pages, it is
best for passing large data between few pages.
ok fist thing you need to do is create an uniq ID for the user, and
pass it along with the url. I tend to use:
$sID = md5("some id text" . $_SERVER['SCRIPT_NAME'] . time());
then on our links use:
a href=/some_page.php?s id=<?php print $sID; ?>
ok, now on your page that has the data, write it to a file (use a
cache dir [make sure it is writeable])
$sesFile = "_cache/$sID";
// open the file, write php head
$fp = fopen($sesFile, "w");
fwrite($fp,"<?p hp\n");
$wInfo = var_export($YOU R_ARRAY_NAME,TR UE);
// write the var name and data
fwrite($fp,"\$" ."YOUR_ARRAY_NA ME = "); // do not put $ on array name!
fwrite($fp,$wIn fo.";\n");
// write php end, and close file
fwrite($fp,"?>\ n");
fclose($fp);
This creates a file that you can load right into a php script to have
your array back
so on the following page that you want your data array available on
use this at the top
$sID = $_GET['sid'];
include("_cache/$sID");
thats it, your array is now loaded and ready to use.
ok, the bad side of this, writing files, and accumulating them, you
need to find a way to delete these files that is best for you, you
could delete the array after you load it, but there is a chance it
wont delete, becouse they never went to the following page.
I have a _cache dir on my server, and delete files over 30 days old,
this could work for you, but then ties you into the server, and sites
are not as portable.
hope this helps,
Mike Bradley
http://gzen.myhq.info -- free online php tools