Reputation: 5192
I am using pdk jdeveloper portlet.
I have deployed ear on tomcat server with host www.test1.com:8080/
now i m using it's provider on oracle server with same host but different port like www.test1.com:9090/
so here i m not able to use cookie or session thing on www.test1.com:9090/
I have set cookie using javascript as below:
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
setCookie("USER","test",365);
now tried to get this cookie on portlet page as below.
PortletRenderRequest pReq = (PortletRenderRequest)
request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
try 1: Cookie[] cookies =request.getCookies(); // get null
try 2: Cookie[] cookies = (Cookie[])pReq.getCookies(); // get null
how can i achieve this ? please help.
Upvotes: -1
Views: 4636
Reputation: 297
You have to set a domain on cookie. link, This gives you a good start. I read this article and found that its easy to share cookie across sub domain but complicated to share it across different domain. This would also be useful link
Upvotes: 0