+ Start a Discussion
Kartheek VarmaKartheek Varma 

how to write the session in force.com sites

  We are trying to build one simple website using force.com sites.Here User logged into the website and need to perform different actions by moving to different VF pages.We are facing a Problem to does not maintain Session of the particular user.We need help regarding how to maintain the session for the particular user.My issue is I Can create  New URL to the site in the web browser by opening from another Browser to save the site URL  as the default home page and automatically display this same page will be displayed. Please give me the solution.
Rahul KumarRahul Kumar (Salesforce Developers) 
Registering a Site domain and Maintaining a Session 
For all those people who want to register and free force.com site and maintain a session for users, I request you to first create a fresh developer.force.com account even if you have one and follow the following steps. 

Instead of finding out why the problem is occurring in your existing portal and debugging it, create a new one and copy all your objects through workbench, copy and paste visual force pages and apex classes to your new force.com account.

1. Customer Portal -> Settings -> Activate the portal, Enable Self Registration, Set Default New User License as Customer Portal Manager Standard, Set Default User Role as User and Default New User Profile as Customer Portal Manager Standard.
2. Create an Account and copy its Account ID
3. Manage Users->Roles->Company size based sample-> Set up Roles->Either Add Role or Assign to an existing role the above account created.
4. Develop->Sites->Search availability and register a domain
5. Edit the Site Details by providing a name and other details. To start with keep the homepage as SiteLogin, Change Password as ChangePassword page and Profile Page as MyProfilePage. 
6. Activate the Site
7. Click on Site Name and go to Login Settings->Edit->Select the customer portal so created
8. Now the site is activated and login is enabled
9. Go to SiteRegisterController page->Edit -> Replace the default PORTAL_ACCOUNT_ID with the above copied Account ID
10. Go to MyProfileController->Edit->Comment the if condition which throws an exception in case of Guest User.
11. Go to SiteLoginController, change the return value of the login method with ‘return Page.MyProfilePage;’
12. Go to Develop ->Sites->Click on Site URL
13. If all the steps are done correctly, the Site will show hyperlinks for NewUser, ForgotPassword, and Login on the Header as well as on the Output Panel. 
14. Click on New User, enter the details and on clicking submit you will be redirected to the Login page. Enter your username and password registered. If all the above steps are done correctly, you will be directed to the MyProfilePage which will show you the logged in user credentials along with change password button and a log out button.
15. Copy paste the same URL in another browser or private browsing or incognito window and you will see the message of authentication required.
16. If you click on Logout, you will be redirected to the login page again.

Please refer the below link for reference.
Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Rahul Kumar