Question about session management

42 views
Skip to first unread message

Tamer Temizer

unread,
Jul 3, 2018, 4:30:41 AM7/3/18
to civetweb

Hello,

In our application we use a cookie based authentication. If the cookie of the user matches our server-side cookie the page should give 200 OK and if they don't match page should give 403 Forbidden. However my wish is not to do something like if (forbidden) mg.write(forbidden message) else mg.write(all of the lp page). I don't want to wrap my html code in mg.write. Is there a better way that civetweb allows? We are serving from document root, not using the C library.

Thanks.

bel

unread,
Jul 3, 2018, 2:47:31 PM7/3/18
to civetweb
A specific *.lua page? Or a whole directory?
Or all *.lua pages everywhere?

Depends ... you could work with a Lua preload file, or an index script.

An index script can check if the cookie is present.
If not it could (a) create a cookie, (b) redirect to login, (c) return 403 forbidden, (d) ... whatever.
If so, it could send the required file (mg.send_file) or execute the required script.

I can add an example of this index script (in a couple of days ... till the weekend).

Tamer Temizer

unread,
Jul 4, 2018, 7:47:22 AM7/4/18
to bel, civetweb
Thanks!

We found the solution by separating our views and pages. Then if authentication is succesful we mg.include(correct view) and if it is not we give 403 and show the forbidden view.

Thanks for the fast reply.

--
Sourceforge
https://sourceforge.net/projects/civetweb/
---
You received this message because you are subscribed to the Google Groups "civetweb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to civetweb+unsubscribe@googlegroups.com.
To post to this group, send email to cive...@googlegroups.com.
Visit this group at https://groups.google.com/group/civetweb.
To view this discussion on the web visit https://groups.google.com/d/msgid/civetweb/b52fe4a5-0a8c-4846-be24-ab81595fc752%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Saygılarımla / Kind Regards,
Tamer Temizer

tel: (0531) 352 97 30
Reply all
Reply to author
Forward
0 new messages