Re: [PHP-WIN] cookies time? - now it doesn't write [SOLVED]
by extremdur2 other posts by this author
Sep 19 2006 3:19AM messages near this date
Re: [PHP-WIN] Reverse DNS/IP
|
Fwd: [PHP-WIN] cookies time? - now it doesn't write
Now I found why under some sizes it worked. It was because in the config
file php.ini, the variable output_buffering was set to "4096". When the
buffer reached that size the rest of the cookie cannot be stored and failed
:)
well, that's what I suppose reading the documentation of this option:
; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files
by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On',
as
; a value for this directive (e.g., output_buffering=4096).
Thank you all :)
2006/9/19, German Piqu� <extremdur2@[...].com> :
>
> I found the problem... and the solution
>
> To test it, i set a group of messages in the code of the class cookie when
> the variable "debug" is active. That was leading to all the errors. It's
> like the script was generating html code and after that it tries to modify
> the cookies.
>
> I set the debug variable to false and only show the cookies' contents
> after the writing to it, and it works with all the strings length I tested.
>
> BTW, how many bytes a caracter in a string consume? In C a char is equal
> to one byte, but I don't know if in php is the same. I want to know to limit
> in the class the cookies' size.
>
> Thanks to all :)
>
> 2006/9/19, German Piqu� <extremdur2@[...].com>:
> >
> >
> >
> > ---------- Forwarded message ----------
> > From: German Piqu� < extremdur2@[...].com>
> > Date: 19-sep-2006 10:38
> > Subject: Re: [PHP-WIN] cookies time? - now it doesn't write
> > To: "Frank M. Kromann" < frank@[...].info>
> >
> > Now works... Oo
> >
> > But i have another problem.
> >
> > My script must check a DB and inform of the changes that have been
> > produced since the last update. I tried two different ways to do it:
> >
> > 1) Use a file in the server to store the diferences
> >
> > 2) Use cookies to store the info.
> >
> > The first solution has the problem that the update will take place for
> > all the users that access the script. I think that would be risky for the
> > integrity of the file or the info retrieved in a case of to much accesses...
> >
> >
> > The second option i think that is better. But i encounter problems.
> > Depending on the content, the setcookie returns an error. The idea of the
> > code is that first search if the cookie exists. If yes, shows it. otherwise,
> > no. After that, when the access to the DB is made, it stores the results in
> > the cookie to be reused again. I tried to avoid the 4 KBs limit problem by
> > creating a class that controls the lenght of the string and if it surpases
> > the limit, creates another cookie, with the increment of a counter attatchet
> > to the base name of the cookie.
> >
> > It's curious that if I put the string manually, it can be larger than
> > one string created through the union of one array's cells.
> >
> > Could it be a memory problem, like the class is taking all of it leaving
> > nothing to the cookies? I think that this sentence has no sense but i don't
> > know what it could be.
> >
> > I tried to destroy the cookies after reading them, too. But when I try
> > to re-create it later in order to insert the new info causes an error, and
> > in the next refresh, there are no cookies and I can write to the cookies!!
> > Then, in the next refresh, again I can read the cookie, but I can't write to
> > it. In the next, there are no cookis and I can write again... Why? Why if
> > the cookie is destroyed I can write it but if it's create I can't rewrite
> > it?
> >
> > That's the cause that leade me to think that it's a memory problem.
> >
> > Well... any ideas?
> >
> >
> >
> > 2006/9/19, German Piqu� <extremdur2@[...].com>:
> > >
> > > So, it's another problem. -_- I'll give it a try.
> > >
> > > 2006/9/18, Frank M. Kromann <frank@[...].info>:
> > >
> > > > both time() and mktime() works fine on Windows.
> > > >
> > > > - Frank
> > > >
> > > > > Well, reading the documentation about cookies i saw that the
> > > > function
> > > > time()
> > > > > works using UNIX epochs. If I try to use this function (or mktime)
> > > > in
> > > > > windows, the php shows a white page, like there's an error
> > > > somewhere.
> > > > >
> > > > > It's a problem with windows machine's or there's another solution
> > > > to
> > > > this?
> > > > >
> > > > > Meanwhile, I put no time option (so cookie expires at the end of
> > > > the
> > > > > session) but i would like to try to set up a timeout.
> > > > >
> > > > > I don't demand absolute solutions, I only want a clue to work on.
> > > > >
> > > > > Thank you :)
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
>
>
|