![]() |
How to test if cookies are being accepted?
I have a little php page that tests if they are behind a firewall and I need it to also see if they have cookies enabled.
|
without doing a redirect after setting a cookie, I don't know of a reliable way to do so.
Basically something like: index.php setcookie ('cookied','yes') header('Location: cookietest.php'); ?> cookietest.php if ($_COOKIE['cookied']) { print "I've got your warm gooey chocolate chip cookie right here"; } ?> There are other methods, this one is pretty much tried and true. That is consquently the behavior that got one of my web sites banned from google for two years :) There might be errors in the code, I didn't test it, but, it should be pretty darn close. |
A redirect would be fine but I can't figure out where I should put that first bit of code.
This is the page I'm using http://cleoslinks.com/info.php |
The one cd34 posted works great, if you dont' mind redirecting pages. I have one piece of code that does the testing through an image instead
On index.php there's an image called image.php image.php sets a cookie and redirects to image2.php. image2.php checks if the cookie exist, if not then you have a non-cookie and you can do whatever you want with it. I'll see if I can find the code. |
; on the setcookie line :)
|
I couldn't find it but I made a quick one: http://nuvisiongroup.com/test/cookietest.html
you should get a green image if you have cookies turned on, red if you don't. http://nuvisiongroup.com/test/cookietest.txt - source for the html page http://nuvisiongroup.com/test/image.phps - source for image.php Doing it that way doesn't fit everybody. But it's a good way to do stealth cookie testing. |
Yours works perfect
Mine naturally doesn't |
|banghead|
I really need to try to learn php… I have a page with the image tag calling up image.php but it is just showing a broken image. http://cleoslinks.com/info.php I notice that I can load your image.php in a browser but if I load mine I get an error on line 10 http://cleoslinks.com/image.php This is what I have in that file http://cleoslinks.com/image.txt |banghead| |
I don't think your server has php4-gd installed
|
PHP Version 4.3.10
Configure Command './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--enable-exif' '--with-gd=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-zlib' '--with-ttf=/usr/local' '--with-freetype-dir=/usr/local' '--enable-gd-native-ttf' '--with-mysql=/usr/local/mysql' '--with-curl' '--with-ncurses' '--enable-cli' '--enable-safe-mode' '--enable-shared' '--enable-static' '--enable-ftp' '--with-mcrypt' '--enable-calendar' '--with-xls' '--with-soap' |
Odd that you're getting an error on that line. Sounds like a missing ;.... but there is no missing ;
You can replace the image part with this instead (if you don't have gd installed) PHP Code:
|
http://nuvisiongroup.com/test/image2.phps
That's what your image.php should look like, once we get the error on line 10 taken care of. Are you 100% sure that image.php and image.txt are exactly the same? (have to ask :)) |
check
phpinfo(); ?> does it make any mention of gd? The compile options look right. Perhaps the php.ini file is missing extension=gd.so |
I got it
http://cleoslinks.com/info.php I turned on invisibles in my editor and realized that I was picking up tabs when I copied and pasted. |
BTW I'm using this page for the ever annoying members of Angel's site for when they send me mail asking me why they are having trouble viewing the feeds or something.
Thanks cd34 and swedguy for the help. :) |
No problem :)
|
All times are GMT -4. The time now is 01:56 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc