The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

cookie check problem

Hi

I have a page (page 1) which checks for the existence of a cookie. If
present a link is displayed, if not a form input box is displayed. Upon
entering an email address into the input box, access is granted to a
subsequent page (page 2). The action attribute of the form looks like this:

action="cgi-bin/formtomailscript2.cgi"

This executes the script fine when the form is submitted but the page
doesn't check for the cookie on later visits (ie it displays the input box
again rather than the link)
If the action attribute is changed to look like this:

Then the script is not executed, but the page successfully checks for the
cookie and displays the link on later visits, rather than the input box.
Appreciate an explanation about what's happening here and how to make sure
the script is executed and the cookie is checked.

the problem is in cookie. It is a security issue - you can specify who can read this coockie:

4th optional parameter in setcookie() is 'path' :

If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.