如果有人嗅探您加密的cookie数据并将其原样发送到服务器怎么办?

This might be an irrelevant question , but I'm wondering whether this can happen..

In HTTPS cookie data like phpssid transfers as an encrypted big random number.

What if someone sniffs that encrypted random number and send it to the server as it is? So the server decrypt that id and allows the hacker to log in as someone else. Is this possible?

Yes, exactly. Cookie data if discovered by a third party may be replayed to replicate functionality. Note that you say someone 'sniffs' the cookie over HTTPS, which, if everything is working as it should, would not happen. If you are asking if the encrypted values of SSL/TLS can be replayed to the same effect, no that cannot happen. The plaintext value is needed for this to work.

The encryption key used during a connection (such as HTTPS) will not be the same for a different connection. The actual key used for the connection is generated randomly on the client and encrypted using the server's public key (found in the certificate). There are multiple sites that describe this but here's one I found that explains it really well.

Note that sniffing the connection would not allow a third party to distinguish which part starts where in the data flow unless it knows the common key.

It is not entirely impossible to hack, considering that the NSA does this all day long, but it requires huge processing power for quite limited results.

What if someone sniffs that encrypted random number and send it to the server as it is?

It won't work. Modern TLS is designed to resist replay attacks at multiple levels:

  • Each client uses an ephemeral key.
  • The sequence number is used in the nonce for AEAD modes.