Zubrag.com
October 23, 2018, 07:10:03 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: pwd protect files in many dirs - issue with IE6 and IE7  (Read 10670 times)
husker
Newbie
*
Posts: 13


« on: May 08, 2007, 09:35:18 PM »

Greetings -

I've put the password_protect script in its own dir and I'm using it to protect many PHP files.

All works great in FireFox - but IE always prompts for a password?

My main index.php file starts like this (where pp.php is the protect script)

Code:
<?php
error_reporting
(E_ALL);
session_start();
include(
"/var/www/pwd/pp.php");

and other php files have this as the first line:
Code:
<?php include ("/var/www/pwd/pp.php"); ?>

so sick of ie I could hurl ...

If I try and cram all the functionality into one file I can get IE to work with the PWD PROT script in a different dir than the PWD PROT script - but not when I try and use other files.

BTW, including the script multiple times gets warnings on redclaring the defines (constants), like this:

Code:
define('TIMEOUT_MINUTES', 30);


Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #1 on: May 09, 2007, 04:36:33 AM »

Hmm, is cookies disabled in IE? the one I'm using seem to work fine Sad
Logged

husker
Newbie
*
Posts: 13


« Reply #2 on: May 10, 2007, 03:31:29 PM »

Hmm, is cookies disabled in IE? the one I'm using seem to work fine Sad

I think you are correct that it is a cookie issue - thanks.

I added this to my scripts that reside in various directories - just above the call to the password protect script:

Code:
echo "<pre>"; print_r($_COOKIE); echo "</pre>";

output in firefox:
Code:
Array
(
    [PHPSESSID] => 4bcd166e89f03bef32589f5db097d36b
    [verify] => 5f4dcc3b5aa765d61d8327deb882cf99
)

output in IE:
Code:
Array
(
    [PHPSESSID] => 3171e1224e2c71bd91ce7a07f1909d6f
)

It looks like cookies are enabled.  However, I'm not sure why the verify cookie is not showing up in IE6/7?  Huh

BTW, I'm on a local unix machine on a private LAN (typical development machine) and I think it might have something to do with the "setcookie" cmd in the script?
Logged
husker
Newbie
*
Posts: 13


« Reply #3 on: May 10, 2007, 11:39:20 PM »

update:

this issue seems to be specific to machines on a private LAN without a valid domainname.

the code works in IE6/IE7 and FireFox when the host is on a "real" machine on the internet.

google and php.net mention issues with cookies in subdirectories across browsers on "localhost" machines - I don't have an answer yet, but I am not sure giving a path of "/" in setcookie() is sufficient.
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #4 on: May 11, 2007, 01:42:04 AM »

Wow!...thats quite a obscure thing, and you would have thought it would have been fixed!...well atleast you can blame Microsoft Smiley
Logged

zubragbillone
Newbie
*
Posts: 9


« Reply #5 on: May 18, 2007, 06:44:57 AM »

Had the same problem.
This worked for me:

http://216.239.59.104/searchq=cache:6UyqP6clRbIJ:www.php.net/setcookie+IE+cookies+subdirectories+localhost&hl=it&ct=clnk&cd=4&gl=it

Sorry for the messy address (it's a php.net forum),  but works.
(Scroll down till you find  mleer's 19-Dec-2002 post,  and insert that single line in php file,  before the 'setcookie' line).

Bye,
Giuseppe

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #6 on: May 18, 2007, 07:08:14 AM »

Your url does not work for me. I think because url is from Google's cache.

Are you referencing this one?    http://www.php.net/setcookie#27819
Logged
zubragbillone
Newbie
*
Posts: 9


« Reply #7 on: May 18, 2007, 07:57:38 AM »

Yes,  and the line I added is

header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');

Now it seems to work even in a private LAN
Best
g
Logged
husker
Newbie
*
Posts: 13


« Reply #8 on: May 18, 2007, 10:17:29 AM »

Thanks - that is a needle in a haystack!

I tried other things on that php.net page - but not that one.

In summary, the solution is to add a header line above the setcookie line, like this:

Code:
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
setcookie("verify", '', $timeout, '/'); // clear password;

correct?  I am not able to test this now - but will later.

Logged
zubragbillone
Newbie
*
Posts: 9


« Reply #9 on: May 18, 2007, 10:45:17 AM »

Correct... it works for me. 
Good luck!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC