0

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.

5
  • Are you trying to create custom login functionality? Standard does not require managing session.
    – Ashwani
    Commented Apr 10, 2017 at 7:56
  • @Ashwani Yes, I'm creating custom login functionality.
    – Amol
    Commented Apr 10, 2017 at 8:26
  • Are you trying to create a Community? Customer's who are logging in are Users or Only Contact? Commented Apr 10, 2017 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
    Commented Apr 10, 2017 at 13:26
  • @wAitIngdOg. customer can login as only contact.
    – Amol
    Commented Apr 11, 2017 at 8:29

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .