-7

Can any give me some idea on how to write the following code in PHP because the below code is in C#

var response = HttpContext.Current.Response;
response.Clear();
response.AppendCookie(new HttpCookie("fileDownloadToken", downloadTokenValue); 
response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}",
desiredFileName)); 
response.Flush();

Thanks in advance

4

1 に答える 1

1

あなたはこれをそのように達成することができます、

<?php

    $downloadTokenValue = 'Youre Value';
    $desiredFileNames = 'Desired File Name Value';

    setcookie("fileDownloadToken", $downloadTokenValue, time()+3600);
    header("content-disposition: attachment;filename=$desiredFileNames"); 
    ?>

その Cookie を読みたい場合は、次のことができecho $_COOKIE["fileDownloadToken"]ます。

于 2012-07-12T08:13:45.853 に答える