Sokar was a funerary god who was worshipped in Saqqara (the necropolis of Memphis, possibly even named after Sokar), but also in Giza (as the lord of Rosetau, which was the entrance to the realm of the dead) and elsewhere.
The domain of Sokar who is on his sand was believed to be deep in the underworld; it is mentioned in the fourth and fifth hour of the so-called Amduat, a funerary text from the New Kingdom, with which several royal tombs in the Valley of the Kings were decorated and which also appeared on later papyri.
On the 26th day of the month Khoiak the festival of Sokar took place, an important funerary celebration that was part of a larger, 10 day festival of Osiris. Since the winter solstice fell also on this date in the Ptolemaic period, the two were linked. The festival of Sokar is much older though; texts from the early history of Egypt already mention it.
Sokar was associated with another god of Memphis, Ptah; the result of this association was the god Ptah-Sokar, who is usually depicted as a falcon or as a man with the head of a falcon. Through his funerary role Sokar was also associated with Osiris, which resulted in the god Ptah-Sokar-Osiris.