I just have two questions:

(1) Is there a way to check via php if the user is set up to accept cookies? This would need to be done the first time an user access a page and NOT via something like isset().

In the documentation of PHP, it says that setcookie() returns an integer. But when I used the following code:
print("$output - cookie is accept = $cookie_accept");

The output is ALWAYS 2 and there is NO
output in the place of $cookie_accept. It seems that $cookie_accept is empty?

What is the best way to check to see if the user is set up to accept cookies?

(2) I am looking for a way for an action to take place only if the user went through a specified gateway page.

For example, I have a gateway page A. On A, there is a button pointing to another page B. On B there is some code that would only be executed if the user came from A. The problem is that due to security issues, I cannot simply pass an argument in the url like B.php3?action=x and I also cannot use
a hidden input in the form to pass variables as that could be viewed in the source. I have thought about generating a random number on page A, inserting it into a database and then pass the user to B with the link B.php3?rand=..., retrieve the random number on page B, if the rand numbers match, then the action is executed. But this method involves additional overhead and I was wondering if there was a more elegant way. HTTP_REFERER is set by the user browser and does not work in all of the cases.

Can anyone help?