I've created a force.com website for Business. Website has customer login & register functionality.

When customer register on website, I'm storing the customer data as a contact in sales force.

I'm stuck on the login functionality. means when customer enter the correct Username and password on site, I have to show pages(it shown user logged in ).

How can i do this?

How maintain the season?

I'm aware of all this thing.

Please guide.

  • Are you trying to create custom login functionality? Standard does not require managing session.
    – Ashwani
    Apr 10 '17 at 7:56
  • @Ashwani Yes, I'm creating custom login functionality.
    – Amol
    Apr 10 '17 at 8:26
  • Are you trying to create a Community? Customer's who are logging in are Users or Only Contact? Apr 10 '17 at 8:47
  • @wAitIngdOg. No I'm creating a public website for company. which has a login, register functionality & I'm using salesforce as a database.
    – Amol
    Apr 10 '17 at 13:26
  • @wAitIngdOg. customer can login as only contact.
    – Amol
    Apr 11 '17 at 8:29

In a login function (based on a username and password or anything else that you like), you should validate username/password, and if OK then store a token on the Contact record. Then use the Cookie class to pass that token to the browser for the logged-in user.

Subsequently on every request from that browser, the cookie will be passed on to the server. So in Apex read the Cookie, validate the passed token against what you have on the Contact record, and if they match, perform the desired action.

See https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_sites_cookie.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.