If someone has that level of access to your system, they can just send themselved the session cookie. Or if the cookie is tied to an IP address, they can just make requests with that cookie from the compromised machine.
If an attacker is running code on your system, you are already lost.
If an attacker is running code on your system, you are already lost.