Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2005-01-31, 12:35 PM   #1
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
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.
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 12:41 PM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
without doing a redirect after setting a cookie, I don't know of a reliable way to do so.

Basically something like:
index.php

<?php
setcookie ('cookied','yes')
header('Location: cookietest.php');
?>

cookietest.php
<?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.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2005-01-31, 12:51 PM   #3
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
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
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 01:20 PM   #4
swedguy
Vagabond
 
swedguy's Avatar
 
Join Date: Aug 2003
Posts: 2,374
Send a message via ICQ to swedguy
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.
swedguy is offline   Reply With Quote
Old 2005-01-31, 01:33 PM   #5
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
; on the setcookie line
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2005-01-31, 01:42 PM   #6
swedguy
Vagabond
 
swedguy's Avatar
 
Join Date: Aug 2003
Posts: 2,374
Send a message via ICQ to swedguy
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.
swedguy is offline   Reply With Quote
Old 2005-01-31, 02:10 PM   #7
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
Yours works perfect

Mine naturally doesn't
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 03:00 PM   #8
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936


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

__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 03:03 PM   #9
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
I don't think your server has php4-gd installed
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2005-01-31, 03:15 PM   #10
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
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'
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 03:19 PM   #11
swedguy
Vagabond
 
swedguy's Avatar
 
Join Date: Aug 2003
Posts: 2,374
Send a message via ICQ to swedguy
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:
header("Content-type: image/gif");
printf ("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%"71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59); 
It's a 1x1 transparent gif.
swedguy is offline   Reply With Quote
Old 2005-01-31, 03:27 PM   #12
swedguy
Vagabond
 
swedguy's Avatar
 
Join Date: Aug 2003
Posts: 2,374
Send a message via ICQ to swedguy
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 )
swedguy is offline   Reply With Quote
Old 2005-01-31, 03:40 PM   #13
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
check

<?php
phpinfo();
?>

does it make any mention of gd?

The compile options look right. Perhaps the php.ini file is missing

extension=gd.so
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2005-01-31, 03:41 PM   #14
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
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.
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 03:44 PM   #15
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
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.
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2005-01-31, 03:49 PM   #16
swedguy
Vagabond
 
swedguy's Avatar
 
Join Date: Aug 2003
Posts: 2,374
Send a message via ICQ to swedguy
No problem
swedguy is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:28 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc