As a refrigerator door gasket gets older it loses its elasticity, becoming hard and somewhat brittle, no longer pliable and able to flex or move to form a good seal between the refrigerator door and the cabinet of the refrigerator.
In some instances the whole gasket will go bad and the refrigerator door will no longer stay shut. In other cases it might just be that part of the gasket will no longer seal. This usually happens around a corner of the door gasket.
If your refrigerator door gasket has become hard and will no longer seal in a few places, you can try to heat the gasket in those hard places, using a hair dryer set on the hottest setting. Holding the hair dryer a few inches away from the gasket, move slowly back and forth over the gasket until it becomes warm to the touch, then shut the refrigerator door, do a visual look around the door and make certain that the gasket is sealed correctly into position and it has not folded or creased anywhere. You may have to use a putty knife to push down on the gasket in places while it is still warm, with the door closed.
Be certain to leave the refrigerator door closed until the gasket has had time to fully cool down. Twenty minutes or so should work fine. Hopefully this brought some new life back into the old gasket and helped to make it seal the refrigerator door properly again.