掲示板
Logout Programmatically - Clearing the cookies
9年前 に venka reddy によって更新されました。
Logout Programmatically - Clearing the cookies
Regular Member 投稿: 231 参加年月日: 11/03/23 最新の投稿
Hi,
I am trying to logout the user programmatically , So I am trying to clear cookies. But not able to clear cookie and also user doesn't logout .
Here is the following snippets.
Cookie[] cookies = actionRequest.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
cookies.setValue("");
cookies.setPath("/");
cookies.setMaxAge(0);
actionResponse.addProperty(cookies);
}
}
Is anything i am going wrong?
I am trying to logout the user programmatically , So I am trying to clear cookies. But not able to clear cookie and also user doesn't logout .
Here is the following snippets.
Cookie[] cookies = actionRequest.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
cookies.setValue("");
cookies.setPath("/");
cookies.setMaxAge(0);
actionResponse.addProperty(cookies);
}
}
Is anything i am going wrong?
9年前 に David H Nebinger によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Cookies on the action request is just for the portlet and does not affect the overall state of login.
9年前 に venka reddy によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Regular Member 投稿: 231 参加年月日: 11/03/23 最新の投稿
hi david,
so i have tried casting actionRequest to httpservlet request. It is not clearing the cookies.
Below is the code i have tried. Any Suggestions to clear the cookies for whole portal in a custom portlet?
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);
HttpSession session = request.getSession();
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
cookies.setValue("");
cookies.setPath("/");
cookies.setMaxAge(0);
response.addCookie(cookies);
}
}
so i have tried casting actionRequest to httpservlet request. It is not clearing the cookies.
Below is the code i have tried. Any Suggestions to clear the cookies for whole portal in a custom portlet?
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);
HttpSession session = request.getSession();
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
cookies.setValue("");
cookies.setPath("/");
cookies.setMaxAge(0);
response.addCookie(cookies);
}
}
9年前 に Meera Prince によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Liferay Legend 投稿: 1111 参加年月日: 11/02/08 最新の投稿
Hi
Please have a look into following source code it may help you..
https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/action/LayoutAction.java
Regards,
Meera prince
http://www.liferaysavvy.com/
Please have a look into following source code it may help you..
https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/action/LayoutAction.java
Regards,
Meera prince
http://www.liferaysavvy.com/
9年前 に Rahul Pande によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Expert 投稿: 310 参加年月日: 10/07/07 最新の投稿venka reddy:
I am trying to logout the user programmatically
Hi Venka,
You can Liferay's default method for logging out the user i.e by calling c/portal/logout instead of manually removing the cookies.
HTH
Rahul Pande
9年前 に venka reddy によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Regular Member 投稿: 231 参加年月日: 11/03/23 最新の投稿
Hi Rahul,
By Calling "c/portal/logout" it is working . But i need to redirect to the custom jsp page after logout. so i am trying to clear cookies programatically which is not happening.
Any suggestions on this?
By Calling "c/portal/logout" it is working . But i need to redirect to the custom jsp page after logout. so i am trying to clear cookies programatically which is not happening.
Any suggestions on this?
9年前 に Anil Sunkari によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Expert 投稿: 427 参加年月日: 09/08/12 最新の投稿
Hi Venka,
I think after "c/portal/logout" using custompostlogoutaction you can redirect to your own/custom.
Refer : https://www.liferay.com/community/forums/-/message_boards/message/14111757
Regards,
Anil Sunkari
I think after "c/portal/logout" using custompostlogoutaction you can redirect to your own/custom.
Refer : https://www.liferay.com/community/forums/-/message_boards/message/14111757
Regards,
Anil Sunkari
9年前 に Rahul Pande によって更新されました。
RE: Logout Programmatically - Clearing the cookies
Expert 投稿: 310 参加年月日: 10/07/07 最新の投稿venka reddy:
But i need to redirect to the custom jsp page after logout. so i am trying to clear cookies programmatically which is not happening.
Any suggestions on this?
Please try setting this property in portal-ext.properties if you want to redirect user to a specific Liferay page.
##
## Default Logout Page
##
#
# Set the default logout page path for users relative to the server path.
# This is the page users are automatically redirected to after logging out.
# For example, if you want the default logout page to be
# http://localhost:8080/web/guest/logout, set this to /web/guest/logout. To
# activate this feature, set auth.forward.by.last.path to true. To customize
# the behavior, see com.liferay.portal.events.DefaultLogoutPageAction in
# the "logout.events.post" property above.
#
default.logout.page.path=
#default.logout.page.path=/web/guest/logout
HTH
Rahul Pande