php-general Digest 26 Mar 2008 04:16:10 -0000 Issue 5368

Topics (messages 272075 through 272105):

Re: Manipulating PDF
        272075 by: Zoltán Németh

Re: Date math
        272076 by: Casey

Re: question about linux editor
        272077 by: Wolf
        272085 by: Ray Hauge

tidy configuration disabled still html is generated
        272078 by: Nilesh Govindrajan
        272081 by: Wolf
        272082 by: Nilesh Govindrajan
        272083 by: Wolf

Re: mysql joins
        272079 by: Wolf

tidy configuration disabled still html is generated <solved>
        272080 by: Nilesh Govindrajan

Re: Beware of round() function
        272084 by: Kirk.Johnson.zootweb.com

loosing session in new window (IE only)
        272086 by: Lamp Lists
        272089 by: Andrew Ballard
        272090 by: Lamp Lists

Re: losing session in new window (IE only) [WAS: loosing...]
        272087 by: Paul Novitski
        272088 by: Lamp Lists

testing
        272091 by: PHP General Users Mailing List
        272092 by: Mark Weaver

Cookie Trouble: getting the information back out...
        272093 by: Mark Weaver
        272095 by: Daniel Brown
        272097 by: Andrew Ballard
        272098 by: Casey
        272100 by: Mark Weaver
        272101 by: Andrew Ballard
        272102 by: Casey
        272103 by: Mark Weaver
        272104 by: Andrew Ballard
        272105 by: Jim Lucas

session var not changed if file not found error
        272094 by: Eric Wood
        272096 by: Daniel Brown
        272099 by: Eric Wood

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
2008. 03. 23, vasárnap keltezéssel 11.57-kor tedd ezt írta:
> At 4:36 PM +0100 3/23/08, Aschwin Wesselius wrote:
> >Again, I'm not after PHPLib or FPDF, since these libraries are 
> >either old or insufficient for what I want.
> 
> Hey, don't discount old things. :-)
> 
> I can do just about anything I want with those old files.
> 
> http://webbytedd.com/bb/pdf/
> 

where's the source for that?

greets,
Zoltán Németh

> Cheers,
> 
> tedd
> 
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 


--- End Message ---
--- Begin Message ---
(top-posting!)

Add either the round function or ceil function.

On Mar 25, 2008, at 6:47 AM, Ron Piggott <[EMAIL PROTECTED]> wrote:


Could someone then help me modify the PHP script so I won't have this
timezone issue? I don't understand from looking at the date page on the
PHP web site the change(s) I need to make.  Thanks, Ron

<?

$date1 = strtotime($date1);
$date2 = strtotime($date2);

$factor = 86400;

$difference = (($date1 - $date2) / $factor);

On Mon, 2008-03-24 at 07:24 -0700, Jim Lucas wrote:
Ron Piggott wrote:
I have this math equation this list helped me generate a few weeks ago. The purpose is to calculate how many days have passed between 2 dates.

Right now my output ($difference) is 93.9583333333 days.

I am finding this a little weird. Does anyone see anything wrong with
the way this is calculated:

$date1 = strtotime($date1); (March 21st 2008)
$date2 = strtotime($date2); (December 18th 2007)

echo $date1 => 1206072000
echo $date2 => 1197954000

#86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days
worth of seconds)

$factor = 86400;

$difference = (($date1 - $date2) / $factor);




As Casey suggested, it is a timestamp issue.

Checkout my test script.

http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php

<plaintext><?php

$date1 = strtotime('March 21st 2008'); //(March 21st 2008)
echo "date1 = {$date1}\n";

$date2 = strtotime('December 18th 2007'); //(December 18th 2007)
echo "date2 = {$date2}\n";

$date1 = 1206072000;
echo date('c', $date1)."\n";

$date2 = 1197954000;

echo date('c', $date2)."\n";


#86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days worth of
seconds)

$factor = 86400;

$difference = (($date1 - $date2) / $factor);

echo $difference."\n";



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
---- Sudhakar <[EMAIL PROTECTED]> wrote: 
> i need to connect to the linux server using an editor. can anyone suggest
> which would be an ideal linux editor to connect to the server.
> apart from the ip address, username and password are there any other details
> i would need to connect to the server.
> 
> please advice.
> 
> thanks.

ssh and putty, depending on what OS you are going to start the connection from.

I personally use vi after connection, though others I know use nano.

But then, this is a PHP list....  

--- End Message ---
--- Begin Message ---
Sudhakar wrote:
i need to connect to the linux server using an editor. can anyone suggest
which would be an ideal linux editor to connect to the server.
apart from the ip address, username and password are there any other details
i would need to connect to the server.

please advice.

thanks.


I also will typically use SSH + vi, but Zend Studio (not sure about Eclipse) can open an SSH connection and edit files that way.

--
Ray Hauge
www.primateapplications.com

--- End Message ---
--- Begin Message ---
I have tried everything.

setting tidy.clean_output = Off or 0 in php.ini OR using ini_set

but still tidy makes a plaintext file html.

help.

--- End Message ---
--- Begin Message ---
---- Nilesh Govindrajan <[EMAIL PROTECTED]> wrote: 
> I have tried everything.
> 
> setting tidy.clean_output = Off or 0 in php.ini OR using ini_set
> 
> but still tidy makes a plaintext file html.
> 
> help.

Contact the creators of Tidy

--- End Message ---
--- Begin Message ---
Wolf wrote:
---- Nilesh Govindrajan <[EMAIL PROTECTED]> wrote:
I have tried everything.

setting tidy.clean_output = Off or 0 in php.ini OR using ini_set

but still tidy makes a plaintext file html.

help.

Contact the creators of Tidy
I told na it was a silly problem. didn't you get it ? the fault was found and fixed. it was a hard-link of php.ini in the scan-dir.
--- End Message ---
--- Begin Message ---
---- Nilesh Govindrajan <[EMAIL PROTECTED]> wrote: 
> Wolf wrote:
> > ---- Nilesh Govindrajan <[EMAIL PROTECTED]> wrote: 
> >   
> >> I have tried everything.
> >>
> >> setting tidy.clean_output = Off or 0 in php.ini OR using ini_set
> >>
> >> but still tidy makes a plaintext file html.
> >>
> >> help.
> >>     
> >
> > Contact the creators of Tidy
> >   
> I told na it was a silly problem. didn't you get it ? the fault was 
> found and fixed. it was a hard-link of php.ini in the scan-dir.
> 

It came through slower...  Typically though a specific package you should be 
checking the specific packages FAQ and user forums, though there are some on 
here who might have the specific package and have it played with as well.



--- End Message ---
--- Begin Message ---
---- Steven Macintyre <[EMAIL PROTECTED]> wrote: 
>  I have three tables, namely;
> 
> User 
> - UID 
> - Firstname
> - Surname
> - Tel
> - Cell
> - Email
> 
> Tracker 
> - UID
> - Points
> 
> Winners
> - UID
> - Datetime (0000-00-00 00:00:00)
> 
> I need to get the following information from the above tables (in my logical 
> sense)
> 
> All users from user with sum(points) as points and datetime > datetime + 14 
> days
> 
> In English, the all users must be selected, excluding the ones that have won 
> in the last 14 days and return all the information and the sum of points
> 
> I suspect I would need to use joins here ... but have no clue how to do so 
> ... I have read up a bit and can work out inner joins from three tables, but 
> not coping with this problem above
> 
> Can someone help me out with this please?
> 
> Many thanks 
> 
> Steven

What PHP code have you written so far?

I personally would do a query on one table then use the results to grab the 
information from the other table.  Some use joins, but I haven't seen a ton of 
time loss between the multi-short calls versus a join..

--- End Message ---
--- Begin Message ---
Nilesh Govindrajan wrote:
I have tried everything.

setting tidy.clean_output = Off or 0 in php.ini OR using ini_set

but still tidy makes a plaintext file html.

help.

I am sorry. :) It was a silly problem. FIXED. :)

--- End Message ---
--- Begin Message ---
Thanks for the info, Jeremy. Regardless of the technical details, my code 
still broke. I am little discouraged that an operation that should be so 
simple has these sorts of gotchas.

BTW, I ended up casting to int as my solution.

Kirk

Jeremy Privett <[EMAIL PROTECTED]> wrote on 03/24/2008 02:04:48 PM:

> Jeremy Privett wrote:
> > [EMAIL PROTECTED] wrote:
> >> Beware: round() apparently has changed its behavior from PHP 4.
> > 
> > This is actually a change in the behavior of the float type, not the 
> > round function. Replace your round() with a cast to float and you'll 
> > see the exact same result.
> >
> 
> Also, as a side-note, the only way I've found to get these numbers to 
> print properly is through either printf or sprintf. Also, you could cast 

> back to an integer, if you explicitly don't need floats.

--- End Message ---
--- Begin Message ---
hi,
i have a list of people on one page. each row, on the end has link <a 
href=person.php?id=123 target=_blank>view details</a>.
it's requested to open detail page in new window.
very few people complained they can't open detail page. all of them use IE.
I wasn't able to reproduce the error, though using GoToMeeting I was able to 
look while customer was doing it.
I put session info on screen to see what's going on and found that new window 
doesn't have session info from "old" window?!? like, new window - new session.

does anybody knows anything about this?

thanks.

-ll




      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

--- End Message ---
--- Begin Message ---
On Tue, Mar 25, 2008 at 3:49 PM, Lamp Lists <[EMAIL PROTECTED]> wrote:
> hi,
>  i have a list of people on one page. each row, on the end has link <a 
> href=person.php?id=123 target=_blank>view details</a>.
>  it's requested to open detail page in new window.
>  very few people complained they can't open detail page. all of them use IE.
>  I wasn't able to reproduce the error, though using GoToMeeting I was able to 
> look while customer was doing it.
>  I put session info on screen to see what's going on and found that new 
> window doesn't have session info from "old" window?!? like, new window - new 
> session.
>
>  does anybody knows anything about this?
>
>  thanks.
>
>  -ll

If they open a new window by clicking on IE (say, on the desktop, the
QuickLaunch bar, or the Start menu), Windows actually opens a new,
totally separate process of IE along side the first. The new one will
share any persistent cookies with the first, since they are written to
the file system, but sessions do not usually use persistent cookies.
As long as your users are opening the new window by clicking a link or
by pressing  Ctrl+N from the first window, the session information
*should* remain in tact.

Andrew

--- End Message ---
--- Begin Message ---
----- Original Message ----
From: Andrew Ballard <[EMAIL PROTECTED]>
To: PHP General list <[EMAIL PROTECTED]>
Sent: Tuesday, March 25, 2008 3:41:35 PM
Subject: Re: [PHP] loosing session in new window (IE only)

On Tue, Mar 25, 2008 at 3:49 PM, Lamp Lists <[EMAIL PROTECTED]> wrote:
> hi,
>  i have a list of people on one page. each row, on the end has link <a 
> href=person.php?id=123 target=_blank>view details</a>.
>  it's requested to open detail page in new window.
>  very few people complained they can't open detail page. all of them use IE.
>  I wasn't able to reproduce the error, though using GoToMeeting I was able to 
> look while customer was doing it.
>  I put session info on screen to see what's going on and found that new 
> window doesn't have session info from "old" window?!? like, new window - new 
> session.
>
>  does anybody knows anything about this?
>
>  thanks.
>
>  -ll

If they open a new window by clicking on IE (say, on the desktop, the
QuickLaunch bar, or the Start menu), Windows actually opens a new,
totally separate process of IE along side the first. The new one will
share any persistent cookies with the first, since they are written to
the file system, but sessions do not usually use persistent cookies.
As long as your users are opening the new window by clicking a link or
by pressing  Ctrl+N from the first window, the session information
*should* remain in tact.

Andrew

should - but don't :D
you're right and  I understand opening new window from "desktop" starts new 
process, but this is happening after visitor hits the link "detail view" and 
that is confusing :(







      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

--- End Message ---
--- Begin Message ---
At 3/25/2008 12:49 PM, Lamp Lists wrote:
i have a list of people on one page. each row, on the end has link <a href=person.php?id=123 target=_blank>view details</a>.
it's requested to open detail page in new window.
very few people complained they can't open detail page. all of them use IE.

Try putting the attribute values in double quotes and see if that helps:

        <a href="person.php?id=123" target="_blank">view details</a>

How does your page validate?  http://validator.w3.org/

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--- End Message ---
--- Begin Message ---
----- Original Message ----
From: Paul Novitski <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Tuesday, March 25, 2008 3:05:43 PM
Subject: Re: [PHP] losing session in new window (IE only) [WAS:  loosing...]

At 3/25/2008 12:49 PM, Lamp Lists wrote:
>i have a list of people on one page. each row, on the end has link 
><a href=person.php?id=123 target=_blank>view details</a>.
>it's requested to open detail page in new window.
>very few people complained they can't open detail page. all of them use IE.

Try putting the attribute values in double quotes and see if that helps:

         <a href="person.php?id=123" target="_blank">view details</a>

How does your page validate?  http://validator.w3.org/

Regards,

Paul


hi paul,
nope. quotes are not an issue.
I'm going to validate the page - I'll post results.

-ll







      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

--- End Message ---
--- Begin Message ---
testing






--- End Message ---
--- Begin Message ---
PHP General Users Mailing List wrote:
testing

so I wasn't imagining things then?

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
Hi all,

I suspect I already know part of the answer to this, but I'm not sure which way to go with it. I've got a project I'm working on and one of the things it's got to do is set cookies and then read them later. When the app was first written I was doing everything in PERL and cookies are fairly straight-forward, however I'm finding cookies in PHP somewhat problematic.

Setting the cookie is a snap, however getting the info back out is, well... problematic.

this is basically what I'm doing, what I'm seeing in the cookie, and what I'm getting back out.

Setting the cookie
==========================
$values = "blah|blah|blah";
setcookie("cookiename", $values, time()+$timevalue);


Inside the Cookie
==========================
Content: blah%7Cblah%7Cblah


Getting info Out Of Cookie
==========================
list($first,$second,$third) = explode("|", $values);


Cookie Test Page
==========================
if (isset($_COOKIE["cookiename"])){
        list($first,$second,$third) = explode('|',$_COOKIE["cookiename"]);
        echo "<p>I found your cookie</p>\n";
        echo "<p>The following Values were Contained in the cookie:<BR>
              Username: $first<BR>
              Password: $second<BR>
              Type    : $third</p>\n";
}
else{
        echo "<p>I wasn't able to find your cookie.</p>\n";
}

Now, I've constructed a cookie_test.php page to check things out and the strange behavior I'm seeing is, upon first execution I get the "else" block, but if I hit the browser's reload button I get the "if" block. At first I thought the cookie wasn't being read at all because of weird characters, but then upon reloading the page and seeing the "if" block being displayed I'm thoroughly confused. It's gotta something simple I'm missing.

and I swear if someone tells me to RTFM I'm gonna shit and go blind cause I haven't got a clue as to "which" part of the FM to read concerning this. :)

thanks,

--
Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
On Tue, Mar 25, 2008 at 9:11 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
> Hi all,
[snip!]
>
>  Cookie Test Page
>  ==========================
>  if (isset($_COOKIE["cookiename"])){
>         list($first,$second,$third) = explode('|',$_COOKIE["cookiename"]);
>         echo "<p>I found your cookie</p>\n";
>         echo "<p>The following Values were Contained in the cookie:<BR>
>               Username: $first<BR>
>               Password: $second<BR>
>               Type    : $third</p>\n";
>  }
>  else{
>         echo "<p>I wasn't able to find your cookie.</p>\n";
>  }
>
>  Now, I've constructed a cookie_test.php page to check things out and the
>  strange behavior I'm seeing is, upon first execution I get the "else"
>  block, but if I hit the browser's reload button I get the "if" block. At
>  first I thought the cookie wasn't being read at all because of weird
>  characters, but then upon reloading the page and seeing the "if" block
>  being displayed I'm thoroughly confused. It's gotta something simple I'm
>  missing.

    Is this block of code executed immediately after the cookie is
set?  Sometimes PHP works too fast for its own good and the client
doesn't even realize it has a cookie yet.  Try setting it with one
page and either sleep()'ing for a bit or forcing a link-click or page
refresh before checking for the cookie.

    Conversely, $_SESSION data is much quicker, since the PHPSESSID
cookie is sent as soon as you initialize the session
(session_start()), and you can then immediately access the variables.

    Proof-of-concept:
<?php
// session-test.php
    session_start();
    $_SESSION['test'] = "This is only a test.";
    echo $_SESSION['test']."<br />\n";
?>

<?php
// cookie-test.php
    setcookie("cookiename","This is a cookie test.",time()+86400);
    echo $_COOKIE['cookiename']."<br />\n";
?>


-- 
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

--- End Message ---
--- Begin Message ---
On Tue, Mar 25, 2008 at 9:31 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
> On Tue, Mar 25, 2008 at 9:11 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
>  > Hi all,
>  [snip!]
>
> >
>  >  Cookie Test Page
>  >  ==========================
>  >  if (isset($_COOKIE["cookiename"])){
>  >         list($first,$second,$third) = explode('|',$_COOKIE["cookiename"]);
>  >         echo "<p>I found your cookie</p>\n";
>  >         echo "<p>The following Values were Contained in the cookie:<BR>
>  >               Username: $first<BR>
>  >               Password: $second<BR>
>  >               Type    : $third</p>\n";
>  >  }
>  >  else{
>  >         echo "<p>I wasn't able to find your cookie.</p>\n";
>  >  }
>  >
>  >  Now, I've constructed a cookie_test.php page to check things out and the
>  >  strange behavior I'm seeing is, upon first execution I get the "else"
>  >  block, but if I hit the browser's reload button I get the "if" block. At
>  >  first I thought the cookie wasn't being read at all because of weird
>  >  characters, but then upon reloading the page and seeing the "if" block
>  >  being displayed I'm thoroughly confused. It's gotta something simple I'm
>  >  missing.
>
>     Is this block of code executed immediately after the cookie is
>  set?  Sometimes PHP works too fast for its own good and the client
>  doesn't even realize it has a cookie yet.  Try setting it with one
>  page and either sleep()'ing for a bit or forcing a link-click or page
>  refresh before checking for the cookie.
>

Um... Cookie data ISN'T available to the same script that sets it. If
you use setcookie(), all it does is send a header to the browser
immediately ahead of the output of your script telling the browser to
store those values in either memory or on disk. The value will not
appear in the $_COOKIE array until the browser requests the next page
and includes the Cookie: header as part of the request.

The part of the manual that applies is this line:

"Once the cookies have been set, they can be accessed on the next page
load with the $_COOKIE or $HTTP_COOKIE_VARS arrays."

$_SESSION variables are available immediately as soon as you set them.
The session cookie still isn't set on the client until the browser
processes the response headers at the end of the transaction, but the
values are already in the array and, if the session cookie works they
will be accessible on successive requests.

Andrew

--- End Message ---
--- Begin Message ---
On Mar 25, 2008, at 6:11 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:

Hi all,

I suspect I already know part of the answer to this, but I'm not sure which way to go with it. I've got a project I'm working on and one of the things it's got to do is set cookies and then read them later. When the app was first written I was doing everything in PERL and cookies are fairly straight-forward, however I'm finding cookies in PHP somewhat problematic.

Setting the cookie is a snap, however getting the info back out is, well... problematic.

this is basically what I'm doing, what I'm seeing in the cookie, and what I'm getting back out.

Setting the cookie
==========================
$values = "blah|blah|blah";
setcookie("cookiename", $values, time()+$timevalue);


Inside the Cookie
==========================
Content: blah%7Cblah%7Cblah


Getting info Out Of Cookie
==========================
list($first,$second,$third) = explode("|", $values);


Cookie Test Page
==========================
if (isset($_COOKIE["cookiename"])){
   list($first,$second,$third) = explode('|',$_COOKIE["cookiename"]);
   echo "<p>I found your cookie</p>\n";
   echo "<p>The following Values were Contained in the cookie:<BR>
         Username: $first<BR>
         Password: $second<BR>
         Type    : $third</p>\n";
}
else{
   echo "<p>I wasn't able to find your cookie.</p>\n";
}

Now, I've constructed a cookie_test.php page to check things out and the strange behavior I'm seeing is, upon first execution I get the "else" block, but if I hit the browser's reload button I get the "if" block. At first I thought the cookie wasn't being read at all because of weird characters, but then upon reloading the page and seeing the "if" block being displayed I'm thoroughly confused. It's gotta something simple I'm missing.

and I swear if someone tells me to RTFM I'm gonna shit and go blind cause I haven't got a clue as to "which" part of the FM to read concerning this. :)

thanks,

--
Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Did you forget the <?php ?> tags?

--- End Message ---
--- Begin Message ---
Andrew Ballard wrote:
On Tue, Mar 25, 2008 at 9:31 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
On Tue, Mar 25, 2008 at 9:11 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
 > Hi all,
 [snip!]

 >  Cookie Test Page
 >  ==========================
 >  if (isset($_COOKIE["cookiename"])){
 >         list($first,$second,$third) = explode('|',$_COOKIE["cookiename"]);
 >         echo "<p>I found your cookie</p>\n";
 >         echo "<p>The following Values were Contained in the cookie:<BR>
 >               Username: $first<BR>
 >               Password: $second<BR>
 >               Type    : $third</p>\n";
 >  }
 >  else{
 >         echo "<p>I wasn't able to find your cookie.</p>\n";
 >  }
 >
 >  Now, I've constructed a cookie_test.php page to check things out and the
 >  strange behavior I'm seeing is, upon first execution I get the "else"
 >  block, but if I hit the browser's reload button I get the "if" block. At
 >  first I thought the cookie wasn't being read at all because of weird
 >  characters, but then upon reloading the page and seeing the "if" block
 >  being displayed I'm thoroughly confused. It's gotta something simple I'm
 >  missing.

    Is this block of code executed immediately after the cookie is
 set?  Sometimes PHP works too fast for its own good and the client
 doesn't even realize it has a cookie yet.  Try setting it with one
 page and either sleep()'ing for a bit or forcing a link-click or page
 refresh before checking for the cookie.


Um... Cookie data ISN'T available to the same script that sets it. If
you use setcookie(), all it does is send a header to the browser
immediately ahead of the output of your script telling the browser to
store those values in either memory or on disk. The value will not
appear in the $_COOKIE array until the browser requests the next page
and includes the Cookie: header as part of the request.

The part of the manual that applies is this line:

"Once the cookies have been set, they can be accessed on the next page
load with the $_COOKIE or $HTTP_COOKIE_VARS arrays."

$_SESSION variables are available immediately as soon as you set them.
The session cookie still isn't set on the client until the browser
processes the response headers at the end of the transaction, but the
values are already in the array and, if the session cookie works they
will be accessible on successive requests.

Andrew


Thank you Andrew... Now it all makes perfect sense. Good grief! there's so much to learn. It seems that Java was easier. ;)

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
On Tue, Mar 25, 2008 at 9:59 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
>  Thank you Andrew... Now it all makes perfect sense. Good grief! there's
>  so much to learn. It seems that Java was easier. ;)

That's not specific to PHP. It's just how http works, so it's the same
for ASP, Perl, I suspect Java and most (if not all) other languages.
There might be a language that sets a cookie when you assign a value
to a special cookie variable, but I'm not familiar with any.

Andrew

--- End Message ---
--- Begin Message --- On Mar 25, 2008, at 7:12 PM, "Andrew Ballard" <[EMAIL PROTECTED]> wrote:

On Tue, Mar 25, 2008 at 9:59 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
Thank you Andrew... Now it all makes perfect sense. Good grief! there's
so much to learn. It seems that Java was easier. ;)

That's not specific to PHP. It's just how http works, so it's the same
for ASP, Perl, I suspect Java and most (if not all) other languages.
There might be a language that sets a cookie when you assign a value
to a special cookie variable, but I'm not familiar with any.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


JavaScript, but that's already on the client.
--- End Message ---
--- Begin Message ---
Andrew Ballard wrote:
On Tue, Mar 25, 2008 at 9:59 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
 Thank you Andrew... Now it all makes perfect sense. Good grief! there's
 so much to learn. It seems that Java was easier. ;)

That's not specific to PHP. It's just how http works, so it's the same
for ASP, Perl, I suspect Java and most (if not all) other languages.
There might be a language that sets a cookie when you assign a value
to a special cookie variable, but I'm not familiar with any.

Andrew


Unless I was doing something differently when I originally wrote this in PERL I don't recall having this issue. At that time I would set the cookie and then redirect (load the index with the full menu) if cookie existed.

Geez! now my $_SESSION isn't persisting to the next page when the screen refreshes. The only thing preventing me from gouging out my eyes right now is that I know I'll get this stuff. It's just a matter of time...

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
On Tue, Mar 25, 2008 at 10:19 PM, Casey <[EMAIL PROTECTED]> wrote:
> On Mar 25, 2008, at 7:12 PM, "Andrew Ballard" <[EMAIL PROTECTED]>
>  wrote:
>
>
>
>  > On Tue, Mar 25, 2008 at 9:59 PM, Mark Weaver <[EMAIL PROTECTED]>
>  > wrote:
>  >> Thank you Andrew... Now it all makes perfect sense. Good grief!
>  >> there's
>  >> so much to learn. It seems that Java was easier. ;)
>  >
>  > That's not specific to PHP. It's just how http works, so it's the same
>  > for ASP, Perl, I suspect Java and most (if not all) other languages.
>  > There might be a language that sets a cookie when you assign a value
>  > to a special cookie variable, but I'm not familiar with any.
>  >
>  > Andrew
>  >
>
>  JavaScript, but that's already on the client.

True, client-side JavaScript would do it. I'm pretty sure that
server-side still would not though.

Andrew

--- End Message ---
--- Begin Message ---
Mark Weaver wrote:
Andrew Ballard wrote:
On Tue, Mar 25, 2008 at 9:59 PM, Mark Weaver <[EMAIL PROTECTED]> wrote:
 Thank you Andrew... Now it all makes perfect sense. Good grief! there's
 so much to learn. It seems that Java was easier. ;)

That's not specific to PHP. It's just how http works, so it's the same
for ASP, Perl, I suspect Java and most (if not all) other languages.
There might be a language that sets a cookie when you assign a value
to a special cookie variable, but I'm not familiar with any.

Andrew


Unless I was doing something differently when I originally wrote this in PERL I don't recall having this issue. At that time I would set the cookie and then redirect (load the index with the full menu) if cookie existed.

Geez! now my $_SESSION isn't persisting to the next page when the screen refreshes. The only thing preventing me from gouging out my eyes right now is that I know I'll get this stuff. It's just a matter of time...


The "problem" that you are encountering is because the $_COOKIE array is "populated" when the script is executed. More then likely the other languages that you used, would allow you to set a cookie and then they would enter them into the "global" array for you, and not make you wait until the next page load.

You could accomplish this yourself by making a wrapper function for the setcookie() function and have your function set the data using setcookie() and having it enter the data directly into the $_COOKIE array.

Something like this should do the trick

<?php
/*
bool setcookie ( string $name
              [, string $value
              [, int $expire
              [, string $path
              [, string $domain
              [, bool $secure
              [, bool $httponly  ]]]]]] )
*/

function mySetCookie($name,
                     $value=null,
                     $expire=0,
                     $path='/',
                     $domain=null,
                     $secure=FALSE,
                     $httponly=FALSE) {

        if ( is_null($domain) )
                $domain = $_SERVER['SERVER_NAME'];

        if ( setcookie( $name, $value, $expire,
                        $path, $domain, $secure, $httponly) ) {
                $_COOKIE[$name] = $value;
                return true;
        }
        return false;
}


?>

--- End Message ---
--- Begin Message ---
This has baffled me all day on my FC6 php-5.1.6 based server.

On a normal working page, I set a session variable at the top and another session variable in the middle of the page/script. This page has no errors nor missing links. So everything works great. Now, if I cause at least 1 image in the page to become missing on the server (ie, by deleting a .jpg file), then Apache logs the error as usual, ie: "File does not exist". But in addition, my two session variables seem to get deleted. If I put the picture(s) back, then no apache errors, and my session vars are set fine.
I've even enabled detailed php error reporting and I get no errors.

Is this normal session behavior? Please say no. Any ideas? I can't understand why missing links would cause a session variable's annihilation.

-eric wood





--- End Message ---
--- Begin Message ---
On Tue, Mar 25, 2008 at 9:29 PM, Eric Wood <[EMAIL PROTECTED]> wrote:
> This has baffled me all day on my FC6 php-5.1.6 based server.
>
>  On a normal working page, I set a session variable at the top and
>  another session variable in the middle of the page/script.  This page
>  has no errors nor missing links.  So everything works great.
>
>  Now, if I cause at least 1 image in the page to become missing on the
>  server (ie, by deleting a .jpg file), then Apache logs the error as
>  usual, ie: "File does not exist".  But in addition, my two session
>  variables seem to get deleted.  If I put the picture(s) back, then no
>  apache errors, and my session vars are set fine.
>
>  I've even enabled detailed php error reporting and I get no errors.
>
>  Is this normal session behavior?  Please say no.  Any ideas?  I can't
>  understand why missing links would cause a session variable's annihilation.

    It's by no means normal behavior, but that doesn't mean that
what's happening for you isn't expected.  Are you clicking a link to
the image and getting the 404 error?  If that's the case, it could be
that your session is dying or expiring when you leave the sanctity of
the page.

    Also, check and see what is included in the 404 response.  Is it a
custom page?  Right-click the missing image and click "view image" to
view the configured 404 response.  There may be a page that is
instantiating its own session, destroying all sessions, or doing
something else that you really don't like.

-- 
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:

    Also, check and see what is included in the 404 response.  Is it a
custom page?  Right-click the missing image and click "view image" to
view the configured 404 response.  There may be a page that is
instantiating its own session, destroying all sessions, or doing
something else that you really don't like.


Thanks Daniel. I believe you have something. I have a custom 404 error page which starts the same session which is already in progress to show the current page. Now these 404 instances also do session updates in the header (because I'm using a template layout, you know). Therefor, the session file is obviously getting trampled on with these custom 404s. Wow, I would not have figured that out anytime soon. I just need to get less fancy with my 404 page, huh?

Thanks,
-eric wood

--- End Message ---

Reply via email to