Session Management with C / CGI

I am looking to write some applications with C and CGI, and now that I have implemented basic functions such as encoding / decoding URIs, HTML encoding / decoding, request / cookie parser, etc. I need to manage sessions. How can I do it? For example, how does PHP manage sessions?

+6
c cgi
source share
2 answers

Save the user ID and SessionID in a cookie, and then save all other data on the server in the database. Do not encode the user and session in the URL, as this leads to session hijacking, even if the user only wants to show the link to a friend.

+5
source share

Since HTTP has no status, you must maintain an identifier that can track your session. Two main ways are to use cookies to store the identifier or embed the identifier in the URL, usually doing URL rewriting.

You can look at WT , which is a web-based toolkit written in C ++. see also this SO question for a list of C ++ web framework. you'll probably find how they handle sessions.

my2c

+5
source share

All Articles