moving companies : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 18 people (72%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I save a variable to a file on the client (without cookies) and retrieve its value later?
How can I save a value to a file on the server?

May 15th, 2000 16:20
Greg Billock, George Federuik, Nathan Wallace,


There is no way to access client side filesystems without cookies (thank 
goodness!) Cookies provide a very restricted way to store information on 
the user's machine. (See cookie() in the PHP manual.)
To write a variable to a file on the server, you can simply do
$f = fopen("file","w");
fwrite($f,$variable);
fclose($f);
and then 
$f = fopen("file","r");
$variable = fgets($r);
fclose($f);