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
RamsRams 

Session settings for visualfoce page

Hi,

 

How to set the session setting for visualforce login page. My requirement is, i have created one visualforce page as login page. If the user is login with username and password it will be redirect to some other page. user name and password i have stored in some other object. I have checked with that details.

 

Now my requirement is, if user is in login, after 1 hour i need to display  pop up with message as 'your session is expired. Please login again'. How can i solve this. Please help me out.

 

Thanks,

Rams

RajaMohanRajaMohan

Hi Ram,

 

Declare the following on the top of your page,

 

<style>
#fade {
    display: none;
    background: #000;
    position: fixed; left: 0; top: 0;
    z-index: 10;
    width: 100%; height: 100%;
    opacity: .80;
    z-index: 9999;
}

.customPopup{
            background-color: white;
            border-style: solid;
            border-width: 2px;
            left: 50%;
            padding:10px;
            position: absolute;
            z-index: 9999;
            opacity:30;
            /* These are the 3 css properties you will need to tweak so the pop
            up displays in the center of the screen. First set the width. Then set
            margin-left to negative half of what the width is. You can also add
            the height property for a fixed size pop up.*/
            width: 750px;
            margin-left: -250px;
            top:100px;
            
        }

</style>

 

<scripttype="text/javascript">    setTimeout(function(){ 
      location.reload();},60000);</script>

and create a formula field in the object where you store the user information, Name the formula field as Time Elapsed,

 

Time Elapsed should be a Number(14,4). Formula is (NOW() - LastModifiedDate) * 84600

 

After <apex:form> declare the following code,

 

<div id="fade"/>

 

<apex:outpuPanel rendered="{UserObject.TimeElapsed__c>3600}">

document.getElementById("fade").style.display = "block";

</apex:outputPanel>

 

<apex:outputPanel id="popup4">
        <apex:outputPanel styleClass="customPopup" id="thepgblksec6" layout="block" rendered="{UserObject.TimeElapsed__c>3600}">
         <apex:pageBlock >
            
               <apex:pageMessage id="ballPageMsg" summary="your session is expired. Please login again" severity="Info" strength="3"/>
          
          </apex:pageBlock>
         </apex:outputPanel>
     </apex:outputPanel>

 

Kindly remember to update the user record while logging in. It is just to set the value of Time Elapsed to Zero (0).

 

 

Regards

Raja

 

 

 

RamsRams

Hi Raja,

 

In this program where you store the user logged in time. Afrer user login in to vf page, After 1 hour i need to show that pop up. Can you please explain me clearly. I am confused some what. Please help me.

 

Thanks

Rams.

RajaMohanRajaMohan

Hi Ram,

 

If you are not stroing the Current User Information then Please create a custom Object and do upsert the record based on the current logged in user ( For Eg. Call the  Object as User Information). In this object create a formula field called  Time Elaspsed with the above mentioed formula. The key is updating/Creating the User Information record based on user logged in. It is initialize the Time Elapsed formula value to Zero when the user logsin in that page.

 

I have not tried this, but I am sure that this logic will work out. Hope the above solution helps you. Let me know If you need any other help.

 

Best Regards

Raja