While I was reading about session hijacking articles, i learned that it would be nice to encrypt session id value that is stored in a cookie.
As far as I know, when I start a session by calling session_start()
, PHP does not encrypt session id value in a cookie.
How do I encrypt session id value and then initialize session with it?
It's always a good idea to never depend on solely on one cookie or item to validate your (logged in) user(s). As mentioned above, it's a good idea to also store the IP and check with that. A good addition would be to store the USER_AGENT.
Bare in mind that if your application is open sourced, you're just as good with a session id alone because the hacker could easily identify what it is you're validating against.
Make this script, access it from a web browser, then check your cookies.
You will likely see something like this
PHP does a fine job if generating a nice, unique id. There's not point in encrypting this.