How long cream cheese lasts after opening varies, but it's not more than a couple of weeks. However, you can freeze cream cheese to keep it good for around two months.
Exposing cream cheese to air is what shortens its shelf life. That means freezing is most useful when that expiration date is creeping ever closer and you haven't opened the box.
Simply freeze the whole package as is (the foil will protect it from freezer burn). Write the freeze date near the expiration date so you know how long it's been in the freezer.
If you've got a block that’s already cut into, keep it intact; more slicing creates more surface for air exposure. Vacuum seal it or give it a tight twirl in cling wrap.
Note that cream cheese from the freezer will be a bit different than cream cheese from the refrigerator. Frozen cream cheese becomes a bit crumbly or gritty upon thawing.