Page 1 of 1

Remember a visitor with no cookies

Posted: Sat Jan 22, 2011 7:31 am
by Vero44
Hi. I have a small bit of php code (running on each page of my website) that remembers the user in a cookie. If the user has cookies turned off I want to be able to carry out an action that prevents this code from running again but allows it to run once only. I understand that session variables are turned off when cookies are turned off.

How can I achieve this? Here's my current code:

Code: Select all

if (isset($_COOKIE['xyz']))  //If my cookie IS set
{
//Do something
}

else //If visitor has no cookie
{

		//nested if

		If (not-sure-what-to-put-here) //If we have been here before
		{
		//Do something to prevent code running again
		} else {
		//code I want to carry out once only
		}
}
Thanks in advance!

Re: Remember a visitor with no cookies

Posted: Sat Jan 22, 2011 11:25 am
by social_experiment
If the user doesn't use cookies it significantly lowers the ways to identify them. You could try checking the IP address (and the remote host name) but that's not a sure fire way to know if it's the same user.

Re: Remember a visitor with no cookies

Posted: Sat Jan 22, 2011 1:52 pm
by John Cartwright
Sessions are not disabled when cookies are disabled. Simply the session id is passed via the URL automagically (enabled via php.ini) whereas it is normally done through cookies transparently.

Re: Remember a visitor with no cookies

Posted: Sat Jan 22, 2011 5:01 pm
by iballeat
You can keep a log of visits, writing the ip of visitors and the date of renewal opportunities entrance. This will be your server cookies.