You are here: Re: Reading a cookie « PHP Programming Language « IT news, forums, messages
Re: Reading a cookie

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация