在java中检索cookieContainer中的数据
我正在使用Unity engine开发一个游戏,它必须将cookie从客户端C#发送到服务器端Java,我面临这个问题(可能是跨平台的问题?我不确定) 我在客户端像这样写了一堆代码在java中检索cookieContainer中的数据,java,c#,cookies,unity5,cookiecontainer,Java,C#,Cookies,Unity5,Cookiecontainer,我正在使用Unity engine开发一个游戏,它必须将cookie从客户端C#发送到服务器端Java,我面临这个问题(可能是跨平台的问题?我不确定) 我在客户端像这样写了一堆代码 private HttpWebRequest request(){ try{ string url = "http://localhost:8080/..."; var request = (HttpWebRequest)WebRequest.Create(url);
private HttpWebRequest request(){
try{
string url = "http://localhost:8080/...";
var request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 15000;
request.KeepAlive = true ;
request.Method= "GET";
CookieContainer cookieContainer = new CookieContainer();
Cookie Authentication = new Cookie("Session" , "09iubasd");
Authentication.Domain = url;
cookieContainer.Add(Authentication);
request.CookieContainer = cookieContainer;
request.Headers.Add("testting", "hascome");
return request;
}catch(System.Exception ex){
Debug.Log("[Exception]" + ex);
throw ex;
}
}
服务器端正在用JavaSpring编写。我无法检索服务器端CookieContainer中的Cookie数据。有谁能给我一些建议或解决办法来解决这个问题吗?或者类似于Java中的CookieContainer。我用谷歌搜索过,但似乎没有办法,如果这是一个愚蠢的问题,那么请教我。非常感谢。
文斯我刚刚找到了我的cookie域设置错误的原因 这里是我刚刚修复的新测试代码。希望这对将来有同样问题的人有所帮助(当然,如果没有人面对这个愚蠢的问题,那一定很好)
private HttpWebRequest request(){
try{
System.Uri uri = new System.Uri("http://localhost:8080/...");
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Timeout = 15000;
request.KeepAlive = true ;
request.Method= "GET";
Cookie Authentication = new Cookie("Session" , "09iubasd");
Authentication.Domain = uri.Host;
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(Authentication);
request.Headers.Add("testting", "hascome");
return request;
}catch(System.Exception ex){
Debug.Log("[Exception]" + ex);
throw ex;
}
}