You need to sign in to do that
Don't have an account?
Jon Mountjoy_
How to log out?
Hi
I'm building in authentication using Customer Portal - and the Site class. This provides methods for logging in, and registration.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm
However, I can't find out how to log out. There is no log out method. How can I do that?
Thanks
Jon
Jon,
there is no class for the logout. when you are logged in you are authenticated as portal user, and portal has a page for logout.
If you look at the out of the box sample SiteHeader component you can find the following line for the logout link for your pages
<apex:outputLink value="{!$Site.Prefix}/secur/logout.jsp" rendered="{!NOT(ISPICKVAL($User.UserType,'Guest'))}">{!$Label.site.logout}</apex:outputLink>
All Answers
Jon,
there is no class for the logout. when you are logged in you are authenticated as portal user, and portal has a page for logout.
If you look at the out of the box sample SiteHeader component you can find the following line for the logout link for your pages
<apex:outputLink value="{!$Site.Prefix}/secur/logout.jsp" rendered="{!NOT(ISPICKVAL($User.UserType,'Guest'))}">{!$Label.site.logout}</apex:outputLink>
I can't seem to get this to actually work in a Force.com Site.
For starters, {!$Site.Prefix}/secur/logout.jsp returns a 404 error when I try to create a link in the context of my site.
And, if I try to hard-link to anything like naX.salesforce.com/secure/logout.jsp, it routes me to the standard SF logout but when I return to my site I'm still logged in as a specific user.
I just tested and it works (<a href="{!$Site.Prefix}/secur/logout.jsp">Logout</a>).
you need to set the logout url to the page that you want to navigate after logout. This is a field on your portal setup page.
Earlier the logout.jsp was working, but the sid(cookie) was not getting purged(deleted). This resulted in not able to re-login in saying an error "user is already logged in"
So found one more setting. Also you need to set "New User Form URL" Customer Portal Setting. For me once I set this, then after logouts the cookie is purged and i am able to re-login without any already logged in error.
Hi Chirag,
Were you able to find a way to perform a silent logout? What about the pagereference?I was able to log out using the pagereference, but I want to redirect the user to the login page after this. Is there a way to do this?
Thanks in advance,
kpr