Forum Moderators: phranque
This is the process,
Step1: A new person comes to the site, we check whether BlahBlahCookie exists or not using htaccess, if not then direct the user to createcookie.php page.
Step2: createcookie.php page creates the cookie and redirects to the requested page.
Step3: System checks and finds the cookie and delievers the requested page.
Problem: Now if cookie is disabled then Step1 checks the cookie and takes the person to createcookie.php. And in step 2 person is redirected to requested page without creating a cookie. So the person comes back to step1(as the cookie is not there) and there is an infinite loop.
Solution: For normal users I can show a message(directing to a different page, defined in htaccess above the cookie check statements) saying you need your cookies enabled to access the site. (Which I will take to do that, as a lot of people do not know what cookie means).
Major problem: What happens to bots, they will never be able to create cookie and access my pages?
Please help me with this,
1) How can I check whether the access is from a bot or a human inside htaccess?
Thanks in advance,
AjiNIMC
RewriteCond %{HTTP_USER_AGENT} Googlebot/¦msnbot/¦Yahoo(\!\ Slurp¦Seeker¦-Vertical) [NC]
RewriteRule ^index\.php$ /index_robot.php [L]
Change all broken pipe characters above to solid pipe characters before use; Posting on this board modifies them.
Jim
However, just like any other cookie, it cannot be detected until the next HTTP request from the client.
Remember that a cookie is 'set' by the server sending the response to the current client request and including the set cookie response header. The cookie (if accepted) is then stored on the client hard drive. After the cookie is set, the client then sends it (in the HTTP request headers) with every subsequent request to the server that set it. Therefore, you cannot verify a cookie within the context of the same HTTP request that set it.
Jim
However, just like any other cookie, it cannot be detected until the next HTTP request from the client.
How can I solve this problem? I need to check whether a person has his/her browser cookie's enabled or disabled.
Step3: System checks and finds the cookie and delievers the requested page.
Thanks Jim
Regards,
AjiNIMC
The answer you have given helped me too.
And I believe that you can help me again. I got stuck with htaccess as usual.
Now the problem I am facing is, how can I check if REFEREL_URL is from the same HTTP_HOST?
Like there is a page [abc.com...] having link to [abc.com...]
I want to check if the user is coming to [abc.com...] from [abc.com...] or from some external domain. In other words I want to check whether this page is referred from internal pages or external ones.
Also can you please help me learn setting a variable in htaccess and using it with a ReWriteCond.
Thanks in advance.
DeveloperMind
OK, I'll have a go:
1) First page check for pre-existing cookie. If set, skip to step 4.
2) Else set a new cookie, redirect to second page.
3) Second page checks for cookie: If cookie set, continue to step 4. If not set, either use session-info-querystring-appended-to-URLs-method, or ask user to allow cookies.
4) User has cookie: End.
Jim