I am using M2Crypto's AES for encrypting message, but confused about how to generate a strong random session key and of what length. Does M2Crypto provide any function for generation random key.
AES-128 has 128 bit key = 16 bytes.
random_key = os.urandom(16)
should be sufficient for most uses. When you feed this random value to M2 (or whatever crypto library), it is transformed internally into a "key schedule" actually used for encryption.