|
Posted by VS on 02/07/07 19:30
Jerim79 wrote:
> Lets say I create a file on my computer called "printer". Inside that
> file I manually type something like: printer=A. How would I send that
> cookie to the PHP form?
Perhaps something like (untested) :
<?php
$Now = time();
$Year=60*60*24*365;
if( !isset($_COOKIE['printer']) ){
if( GetPrinter() ){
setcookie("printer",$Printer,$Now+$Year);
}
}else{
$Printer = $_COOKIE['printer']
}
Function GetPrinter
{
global $Printer;
$Printer = "";
$FL = @fopen("/xxx/printer", 'r');
if( $FL ) {
$buffer = fgets($FL);
list($key, $Value) = split("=",$buffer);
if( $key = "printer" ){
$Printer = $Value;
break;
}
}
fclose($FL);
return ($Printer <> "");
}
?>
--
VS
Navigation:
[Reply to this message]
|