Forums de discussion
Logout Programmatically - Clearing the cookies
venka reddy, modifié il y a 9 années.
Logout Programmatically - Clearing the cookies
Regular Member Publications: 231 Date d'inscription: 23/03/11 Publications récentes
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?
David H Nebinger, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Liferay Legend Publications: 14916 Date d'inscription: 02/09/06 Publications récentes
Cookies on the action request is just for the portlet and does not affect the overall state of login.
venka reddy, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Regular Member Publications: 231 Date d'inscription: 23/03/11 Publications récentes
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);
}
}
Meera Prince, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Liferay Legend Publications: 1111 Date d'inscription: 08/02/11 Publications récentes
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/
Rahul Pande, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Expert Publications: 310 Date d'inscription: 07/07/10 Publications récentesvenka 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
venka reddy, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Regular Member Publications: 231 Date d'inscription: 23/03/11 Publications récentes
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?
Anil Sunkari, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Expert Publications: 427 Date d'inscription: 12/08/09 Publications récentes
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
Rahul Pande, modifié il y a 9 années.
RE: Logout Programmatically - Clearing the cookies
Expert Publications: 310 Date d'inscription: 07/07/10 Publications récentesvenka 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