Hello.
I coding a site. I intend the user to see a sign “Welcome” displayed on the top of index.php, when they enter to see the first page (supposing that that is the page they arrive at the site). Then the user can go to see other pages in the site, eg products.php or contact.php and later when they return to index.php the sign “Welcome” will no longer be there (they have been already welcomed).
I have approached the problem with php session variables. Here is my code of index.php:
[code]if($_SESSION[“mynumber”]!=1){include ‘welcome.txt’;}
else{$_SESSION[“mynumber”] = 1;include ‘welcomealternative.txt’;}
I find this problem difficult. If I set a session variable to 1 when a user enters index.php, and then increase it on every other page by one, when they return to index.php, it will be given value of one and the user will be welcomed. Which is not good.
The problem can get more difficult if we consider cases, when the user arrives to the site to a page different than the index.php…
What is the best solution here?