请问:Delphi如何创建Cookie文件。
具体是这样的:我通过IdHttp访问一个登陆地址,获取一个加密字符串。我想把这个加密字符串写成一个Cookie文件。
怎么做?
注意:是创建Cookie文件,不是修改Cookie文件。

解决方案 »

  1.   

    设置Cookie的话可以用
    InternetSetCookie函数示例:
    InternetSetCookie(url,NULL,L"CookieTest=ValTest;path=path value;expires=Thu, 01-Jan-1970 00:00:01 GMT");
    使用InternetSetCookie删除cookie ms没有官方文档。经过无数次的测试之后发现:
    1。 删除时一定要传入path参数,而且此参数必须和set是一致.
    2。 setcookie是不带path参数则是对当前path起作用(如果url是一个文件的话,MS有问题)
    3。 不同path值,即使cookie的名字一样也是两个不同的cookie。所以path很重要啊!
    转载:http://blog.csdn.net/wewaa/article/details/6347245
      

  2.   

    http://www.codesky.net/article/doc/200308/200308073611906.htm
      

  3.   

    这个函数就是创建Cookie。
    看MSDN:
    This function creates a cookie associated with the specified URL.....
    Cookies created by this function without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.Creating a new cookie might cause a dialog box to appear on the screen if the appropriate registry value, AllowCookies, is set. There is no way to change the registry value from a WinInet function in Windows CE.
    如果指定失效时间的话,他就会在windows\cookies文件夹内创建一个Cookie,如果不指定的话就仅限于当前进程