Improved session ID generation

Added checks for openssl_random_pseudo_bytes and mcrypt_create_iv and use them where possible.