function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Login and re-direction functionality in portal



I have a functionality where users would click on the register link.


a) if users are logged in to the portal and click on the register link, i need to insert a record in my custom object  who clicked on the register link (Contact info : email, name) and  display thanks for registering in VF page.


b) If users are not logged in to the portal(are on site) and click on the register link, system should re-direct the user to portal login page and upon successful login users should come back to this register link page and functionality of a).


I am confused about the re-direction to login page and upon successful login how to re-direct the user to same page from where user clicked on register link. Can some one provide sample code?





Best Answer chosen by Admin (Salesforce Developers) 
dotnet developedotnet develope

Hi Friend,


 I understood the your requirement.

 your can redirect to login page by defining this in your controller method


PageReference pr = new PageReference('/secur/logout.jsp');


return pr;