If you're the owner, read php.ini for the path and check the dir it lists as the session path for permissions. If you're not the owner, you'll likely need to talk to him/her/them.
Of course, your point that the problem is inconsistent raises some difficulties, doesn't it? The script you've quoted above, for example, doesn't ALWAYS work??