My student told me his mother has cancer, what do I do? Today I saw that one of my students in the class was looking very sad. He sat down at the end of class and he looked like he was in a bad mood. After all the students left the classroom I called  him over. He told me that his mother has cancer. 

I told him be strong and try to not think about it too much. But honestly, this was a big lie. How can I try to get him to not think too much of it?

What should I have said to him?
As an instructor, the best you can do is to offer your condolences and tell him to just ask you if he needs anything. For example, you could offer an extension on assignments. If he needs some time off from lectures, maybe a classmate who takes good lecture notes will agree to make a photocopy, or you could get the lectures to be recorded for him.

Your university might also have a policy that allows students to withdraw from the course and receive a refund of fees without penalty to grades: it would be worth finding this out and advising your student if this is possible. Depending on the severity of the illness and how much it is affecting your student, he might wish to take fewer (or zero) courses for a while.

If the course is nearly finished, perhaps an aegrotat (compassionate consideration) will be applicable to the final exam. But neither an illness in the family, nor a bereavement or any personal physical or mental health issue can excuse a student from having to learn the material and complete assessments in order to pass a course. He will still have to demonstrate mastery of most of the material.

Just be compassionate, and as flexible as you feasibly can. Nobody could ask for more.