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
Carson HuangCarson Huang 

Redirect To Another VF Page if user not logged in

Hi guys,

So what's happening is that I have two VF pages right now: a login page and an another VF page. Right now, a user can bypass the login page simply by writing the url for the second VF page. Is there any way to redirect the user to the login page if he's not logged in? I have already written the code to verify whether a user is logged in or not for the controller of the 2nd VF page. However, I am not able to redirect him, since that would require me to load the 2nd VF page first.

Thanks a lot!
Avijit Chakraborty 11Avijit Chakraborty 11
pass a value always to the 2nd vf page on the URL write an action on page load see if the variable is there or not if not then return the page reference of 1st ele return null . hope it will help