Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
Is it possible to set a cookie on a website, with the server side code being in C? I'd assume that I'd have to use a library....? Thanks....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Mar 2013
    Posts
    486

    Server side programming in C


    Is it possible to set a cookie on a website, with the server side code being in C? I'd assume that I'd have to use a library....?



    Thanks.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,930
    Yes, you should use a library. Surely you're already using a library that provides the web framework (you wouldn't be creating that from scratch would you)? Your framework library should already provide cookie management in some way. There seem to be several web toolkit solutions for C++ but very few (I couldn't find any) for C.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux User
    Join Date
    Mar 2013
    Posts
    486
    No, I'm not creating it from scratch, although that wouldn't be that bad of a project for a lazy day in the future or something....!

    I had posted earlier right here, and found out about "template engines", someone had posted a Wikipedia page with comparisons of them, however there were tons of them on the page, and I hadn't really settled on which one to use, indeed on whether that is what I need or not.

    Goddamnation! Someone must have made a C library no?

  4. $spacer_open
    $spacer_close
  5. #4
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,930
    Don't worry overly about the C library. If you're stuck, you can always use a C++ one and only write C code to talk to it (you may have to make some concessions to C++ of course when calling the framework, but hey, you actually gain some good stuff with C++ so it's not all bad).
    Linux user #126863 - see http://linuxcounter.net/

  6. #5
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    1,652
    Presuming your writing for CGI and not creating a server from scratch there's many. i.e. Infodrom Projects -- Lightweight CGI Library

  7. #6
    Just Joined!
    Join Date
    Aug 2014
    Posts
    2
    Yes as per my knowledge you can use a library which provides the web framework and that framework library should provide cookie management.

  8. #7
    Linux User
    Join Date
    Mar 2013
    Posts
    486
    Thanks guys, specially greg.

    Just to let you know, I'm still veering back to PHP for doing my page, I came to the conclusion that trying to make an artistic page by using C (which I don't know that well) would drive me absolutely crazy! But I'll take a bigger look at that Infodrom page sometime, greg!

    How much difference is there between an EXE and interpreted PHP anyway? Didn't I read somewhere on this very site that PHP is quite good?

  9. #8
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    1,652
    There's a large difference between them in all kinds of ways but it is a web page and a well written PHP site will be good enough. PHP is a language that programmers love to hate because it's easy to make a site that is full of security vulnerabilities. It is also easy to write ugly unmaintainable code. There are an enormous number of very good sites using it though and it comes with a large number of interesting libraries.

  10. #9
    Linux User
    Join Date
    Mar 2013
    Posts
    486
    That's not what I was saying. My question was about the difference between interpreted and compiled, both for speed and RAM use. Speed is what somebody said was good, but as far as memory goes,... it has to start up a new instance of MySQL, PHP AND Apache for each hit right? That must be BAD compared to a tiny EXE....?

  11. #10
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    1,652
    Quote Originally Posted by resetreset View Post
    That's not what I was saying. My question was about the difference between interpreted and compiled, both for speed and RAM use. Speed is what somebody said was good, but as far as memory goes,... it has to start up a new instance of MySQL, PHP AND Apache for each hit right? That must be BAD compared to a tiny EXE....?
    That's what I answered. PHP is good enough.

    No. MySQL and Apache are daemons and with FastCGI the cgi applications are resident in memory already (PHP is a CGI application). However, PHP is an interpreted language and slower and uses more memory then an executable.

    If you are thinking of writing a C server rather then using it for CGI it's a whole different affair. There are many ways to create a web page but for someone of little experience that's not one. Someone with a lot of experience wouldn't do it that way anyway.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •