cookie和桌面应用程序 [英] cookies and desktop application

查看:126
本文介绍了cookie和桌面应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,网站向浏览器发送cookie以维护某些州和浏览器将其存储在本地。当再次访问该网站时,浏览器会将这些cookie作为请求的一部分发送回网站。我认为cookie是特定于浏览器的东西。我希望澄清这种理解。连接到Web服务的桌面应用程序是否可以支持cookie?

As I know, websites send cookies to browsers for maintaining some state and browser stores it locally. When that website is visited again, browser sends those cookies back to the website as a part of the request. I am under the impression that cookie is a browser-specific thing. I wanted to get this understanding clarified. Can desktop applications which connect to web services support cookies?

我们有一个Web应用程序,我们正在尝试从桌面应用程序(如Adobe应用程序)设置通信。对于会话管理,我想知道如果桌面应用程序支持,我们是否可以在cookie中编写身份验证令牌。

We have a web application and we are trying to setup communication from desktop applications such as Adobe apps. For session management I was wondering if we can write an auth token in a cookie if that is supported by desktop apps.

推荐答案

是,那很有可能。当你从服务器收到http回复(可能使用winhttp或curl)时,查找http标题'Set-Cookie'它会像

Yes, thats very much possible. When you receive the http reply from the server (probably using winhttp or curl) look for the http header 'Set-Cookie' It will be something like

 Set-Cookie: name2=value2; Expires=Wed, 09 Jun 2021 10:18:14 GMT

cookie名称是name2及其值是value2,它在2021年到期。将它存储在应用程序上下文中的某个位置。所有到期验证都必须由您的申请完成。如果您想使用cookie发出请求,请设置其他请求标头'Cookie'

The cookie name is name2 and its value is value2 and it expires on 2021. Store this somewhere in your application context. All the expiry verification has to be done by your application. When you want to make a request with the cookie, set the additional request header 'Cookie'

 Cookie: name2=value2

如果您使用winhttp,WinHttpAddRequestHeaders和WinHttpQueryHeaders调用将对执行此任务很有用。

If you are using winhttp WinHttpAddRequestHeaders and WinHttpQueryHeaders calls will be useful to do this task.

这篇关于cookie和桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆