xbuilder wrote:I have learnt that cookies have to be set in the html header. If I had a html form which collects user inputs, is it the only to set cookies for the user selections is to call setcookie() in the next page after user clicking a submit botton?
Yes, unless you do it in JavaScript or something.
xbuilder wrote:Also, I have read some online comments about cookie vs. session variables. Any suggestions on using them (do I need to use both or just one of them if sufficient)?
It depends what you want to do. Session data lasts while the users browser is open. Ie, you log into a website, it uses session information, if you restart your browser it logs you out.
if you combine this with cookies you can provide remember me functions to websites. since cookies expire after a specified period of time.