php-general Digest 1 Apr 2011 08:28:26 -0000 Issue 7253
Topics (messages 312157 through 312186):
If Statements Array and Notice Undefined Index
312157 by: Nicholas Cooper
312158 by: Stuart Dallas
312161 by: Nicholas Cooper
312184 by: Al
Re: session_start() may take 5 seconds :(
312159 by: Tolas Anon
312160 by: Tolas Anon
neubie seeking answers
312162 by: Kirk Bailey
312163 by: Richard Quadling
312164 by: Stuart Dallas
312165 by: Steve Staples
312166 by: Steve Staples
312185 by: Kirk Bailey
312186 by: Stuart Dallas
Closing Session
312167 by: Ethan Rosenberg
312168 by: Jay Blanchard
312169 by: Daniel Brown
312170 by: Ethan Rosenberg
312171 by: Ashley Sheridan
312173 by: Daniel Brown
312175 by: Ethan Rosenberg
312176 by: Daniel Brown
312177 by: Ashley Sheridan
312178 by: Steve Staples
312179 by: Stuart Dallas
312181 by: Ethan Rosenberg
312182 by: Ethan Rosenberg
Re: is there a static constructor?
312172 by: Admin
Re: session variable problem
312174 by: markb
PHP 5.2.x with MySQL 5.5.x
312180 by: Andre Matos
Re: Sessions - More Info
312183 by: Boers Steven
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Good day,
I have three arrays A, B and C. Anyone of them might not have the 'id' key
set which will give the Notice "Undefined index: id".
I just wanted to know what the correct approach to this problem would be;
without making the code overly complicated to read by introducing a number
of "if isset" statements.
if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
}
I have notices switched off, but I want to know the right way to do this.
There's probably a number of different right ways to solve this, how would
you do it?
Best Regards,
Nicholas
--- End Message ---
--- Begin Message ---
On Thursday, 31 March 2011 at 15:45, Nicholas Cooper wrote:
Good day,
>
> I have three arrays A, B and C. Anyone of them might not have the 'id' key
> set which will give the Notice "Undefined index: id".
>
> I just wanted to know what the correct approach to this problem would be;
> without making the code overly complicated to read by introducing a number
> of "if isset" statements.
>
> if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
>
> }
>
> I have notices switched off, but I want to know the right way to do this.
> There's probably a number of different right ways to solve this, how would
> you do it?
This is how I handle this...
// Define this function somewhere global
function ifsetor($array, $key, $default = null)
{
return (isset($array[$key]) ? $array[$key] : $default);
}
if (ifsetor($arrayA, 'id') == ifsetor($arrayB, 'id') || ifsetor($arrayC, 'id')
== ifsetor($arrayB, 'id'))...
If you need to avoid a match if neither $arrayA nor $arrayB have an id you
simply pass a different default for each one.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
On 31 March 2011 15:53, Stuart Dallas <stu...@3ft9.com> wrote:
> On Thursday, 31 March 2011 at 15:45, Nicholas Cooper wrote:
> Good day,
> >
> > I have three arrays A, B and C. Anyone of them might not have the 'id'
> key
> > set which will give the Notice "Undefined index: id".
> >
> > I just wanted to know what the correct approach to this problem would be;
> > without making the code overly complicated to read by introducing a
> number
> > of "if isset" statements.
> >
> > if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
> >
> > }
> >
> > I have notices switched off, but I want to know the right way to do this.
> > There's probably a number of different right ways to solve this, how
> would
> > you do it?
>
> This is how I handle this...
>
> // Define this function somewhere global
> function ifsetor($array, $key, $default = null)
> {
> return (isset($array[$key]) ? $array[$key] : $default);
> }
>
> if (ifsetor($arrayA, 'id') == ifsetor($arrayB, 'id') || ifsetor($arrayC,
> 'id') == ifsetor($arrayB, 'id'))...
>
> If you need to avoid a match if neither $arrayA nor $arrayB have an id you
> simply pass a different default for each one.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
>
> http://3ft9.com/
>
>
>
>
Thank you, that is quiet an elegant solution.
Very little additional code excluding the function and it could also easily
be extended for multi dimensional arrays by changing $key to an array and
looping through each index in turn.
Best Regards
Nicholas
--- End Message ---
--- Begin Message ---
On 3/31/2011 10:45 AM, Nicholas Cooper wrote:
Good day,
I have three arrays A, B and C. Anyone of them might not have the 'id' key
set which will give the Notice "Undefined index: id".
I just wanted to know what the correct approach to this problem would be;
without making the code overly complicated to read by introducing a number
of "if isset" statements.
if ($arrayA['id'] == $arrayB['id'] || $arrayC['id'] == $arrayB['id']) {
}
I have notices switched off, but I want to know the right way to do this.
There's probably a number of different right ways to solve this, how would
you do it?
Best Regards,
Nicholas
Check out array_intersect_assoc() or one of the similar functions.
--- End Message ---
--- Begin Message ---
On Thu, Mar 31, 2011 at 7:58 AM, Tolas Anon <tolas...@gmail.com> wrote:
> My web-app sometimes takes just over 5 seconds to execute a single
> start_session() statement.
> No other connections are open to the site when i hit the button that
> makes this happen, the session is just 78kb on a local disk, and it's
> consistent behavior.
> So far, it only happens when i request certain page content via AJAX,
> but I'd like to get rid of it asap.
> Strangely, some other page content requested under the same conditions
> via the same pipeline returns without the delay. It doesn't do
> anything differently except the business code, and the session is
> opened in app-wide generic code that is executed before the business
> code is executed. The very timing with microtime() happens before the
> business code executes.
>
> I've already googled, but haven't found anything useful.
>
> It's on a windows box (latest wampserver) and due to a ubuntu firefox
> limitation i can't test on linux at the moment, nor run strace on it
> :(
>
This afternoon, all my business logic had the same delay, due to
session_start().
I bypassed the ubuntu firefox problem and was able to test under
linux; no delay.
So i'll mail the wampserver admin of this problem, and continue under ubuntu.
--- End Message ---
--- Begin Message ---
On Thu, Mar 31, 2011 at 4:53 PM, Tolas Anon <tolas...@gmail.com> wrote:
> On Thu, Mar 31, 2011 at 7:58 AM, Tolas Anon <tolas...@gmail.com> wrote:
>> My web-app sometimes takes just over 5 seconds to execute a single
>> start_session() statement.
>> No other connections are open to the site when i hit the button that
>> makes this happen, the session is just 78kb on a local disk, and it's
>> consistent behavior.
>> So far, it only happens when i request certain page content via AJAX,
>> but I'd like to get rid of it asap.
>> Strangely, some other page content requested under the same conditions
>> via the same pipeline returns without the delay. It doesn't do
>> anything differently except the business code, and the session is
>> opened in app-wide generic code that is executed before the business
>> code is executed. The very timing with microtime() happens before the
>> business code executes.
>>
>> I've already googled, but haven't found anything useful.
>>
>> It's on a windows box (latest wampserver) and due to a ubuntu firefox
>> limitation i can't test on linux at the moment, nor run strace on it
>> :(
>>
>
> This afternoon, all my business logic had the same delay, due to
> session_start().
>
> I bypassed the ubuntu firefox problem and was able to test under
> linux; no delay.
>
> So i'll mail the wampserver admin of this problem, and continue under ubuntu.
>
http://www.wampserver.com/phorum/read.php?2,72729
--- End Message ---
--- Begin Message ---
I need to extract the name of the subdirectory a page lives in to
use in the title for that page. This will be returned as a string to
echo to the output stream. Now how the heck do I do that?!?
--
end
Very Truly yours,
- Kirk Bailey,
Largo Florida
kniht
+-----+
| BOX |
+-----+
think
--- End Message ---
--- Begin Message ---
On 31 March 2011 17:24, Kirk Bailey <kbai...@howlermonkey.net> wrote:
> I need to extract the name of the subdirectory a page lives in to use in the
> title for that page. This will be returned as a string to echo to the output
> stream. Now how the heck do I do that?!?
__DIR__ is the name of the directory that the __FILE__ resides in.
basename(__DIR__) will give you the directory at the end of the path
that this __FILE__ is in.
So, for ...
C:\PHP\Scripts\script.php
<?php
echo __FILE__, PHP_EOL, __DIR__, PHP_EOL, basename(__DIR__);
?>
will show
C:\PHP\Scripts\script.php
C:\PHP\Scripts
Scripts
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
I need to extract the name of the subdirectory a page lives in to
> use in the title for that page. This will be returned as a string to
> echo to the output stream. Now how the heck do I do that?!?
$dir = basename(dirname(__FILE__));
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
On Thu, 2011-03-31 at 12:24 -0400, Kirk Bailey wrote:
> I need to extract the name of the subdirectory a page lives in to
> use in the title for that page. This will be returned as a string to
> echo to the output stream. Now how the heck do I do that?!?
>
> --
> end
>
> Very Truly yours,
> - Kirk Bailey,
> Largo Florida
>
> kniht
> +-----+
> | BOX |
> +-----+
> think
>
>
I am SURE that there is a better reply already... but quick and dirty...
<?php
$t = explode('/', dirname(__FILE__));
echo $t[count($t) - 1];
?>
--- End Message ---
--- Begin Message ---
On Thu, 2011-03-31 at 17:34 +0100, Stuart Dallas wrote:
> On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
> I need to extract the name of the subdirectory a page lives in to
> > use in the title for that page. This will be returned as a string to
> > echo to the output stream. Now how the heck do I do that?!?
>
> $dir = basename(dirname(__FILE__));
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
That is what I was thinking... but for some reason, I couldn't remember
it... so I did that whole explode() thing... oh well! Kirk, use that :)
--- End Message ---
--- Begin Message ---
PERFECT SIMPLE SOLUTION. THANK YOU!
On 3/31/2011 12:34 PM, Stuart Dallas wrote:
On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
I need to extract the name of the subdirectory a page lives in to
use in the title for that page. This will be returned as a string to
echo to the output stream. Now how the heck do I do that?!?
$dir = basename(dirname(__FILE__));
-Stuart
--
end
Very Truly yours,
- Kirk Bailey,
Largo Florida
kniht
+-----+
| BOX |
+-----+
think
--- End Message ---
--- Begin Message ---
On Friday, 1 April 2011 at 03:31, Kirk Bailey wrote:
PERFECT SIMPLE SOLUTION. THANK YOU!
As Richard noted there is a constant called __DIR__ which is equivalent to
dirname(__FILE__) so basename(__DIR__) will give you what you want and saves a
few cycles.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
> On 3/31/2011 12:34 PM, Stuart Dallas wrote:
> > On Thursday, 31 March 2011 at 17:24, Kirk Bailey wrote:
> > I need to extract the name of the subdirectory a page lives in to
> > > use in the title for that page. This will be returned as a string to
> > > echo to the output stream. Now how the heck do I do that?!?
> > $dir = basename(dirname(__FILE__));
> >
> > -Stuart
>
> --
> end
>
> Very Truly yours,
> - Kirk Bailey,
> Largo Florida
>
> kniht
> +-----+
> | BOX |
> +-----+
> think
>
--- End Message ---
--- Begin Message ---
Dear List -
Thanks for your help.
How do I close a session form the terminal? I need the ability to do
this for debugging. I often have more than one session open at the
same time, so creating a program with session_start() and
session_unset() or session_destoy() would probably not work.
Ethan
--- End Message ---
--- Begin Message ---
[snip]How do I close a session form the terminal?[/snip]
http://php.net/manual/en/function.session-destroy.php
--- End Message ---
--- Begin Message ---
On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg <eth...@earthlink.net> wrote:
> Dear List -
>
> Thanks for your help.
>
> How do I close a session form the terminal? I need the ability to do this
> for debugging. I often have more than one session open at the same time, so
> creating a program with session_start() and session_unset() or
> session_destoy() would probably not work.
Can you rephrase the question, Ethan, or give more details? From
the way it sounds, you're concerned that destroying a session will
have implications for other sessions as well, which is not the case
(unless all sessions are shared). For example, if you have Chrome,
Firefox, and Internet Exploder all active, the sessions should be
different, if even from the very same computer. However, multiple
tabs in the same browser will generally be the same session (unless
it's something like Chrome's Incognito feature).
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
At 01:30 PM 3/31/2011, Daniel Brown wrote:
On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg <eth...@earthlink.net> wrote:
> Dear List -
>
> Thanks for your help.
>
> How do I close a session form the terminal? I need the ability to do this
> for debugging. I often have more than one session open at the
same time, so
> creating a program with session_start() and session_unset() or
> session_destoy() would probably not work.
Can you rephrase the question, Ethan, or give more details? From
the way it sounds, you're concerned that destroying a session will
have implications for other sessions as well, which is not the case
(unless all sessions are shared). For example, if you have Chrome,
Firefox, and Internet Exploder all active, the sessions should be
different, if even from the very same computer. However, multiple
tabs in the same browser will generally be the same session (unless
it's something like Chrome's Incognito feature).
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
=========
Thanks.
Multiple tabs in the same browser will generally be the same session.
That is what I have.
Ethan
--- End Message ---
--- Begin Message ---
On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:
> At 01:30 PM 3/31/2011, Daniel Brown wrote:
> >On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg <eth...@earthlink.net> wrote:
> > > Dear List -
> > >
> > > Thanks for your help.
> > >
> > > How do I close a session form the terminal? I need the ability to do this
> > > for debugging. I often have more than one session open at the
> > same time, so
> > > creating a program with session_start() and session_unset() or
> > > session_destoy() would probably not work.
> >
> > Can you rephrase the question, Ethan, or give more details? From
> >the way it sounds, you're concerned that destroying a session will
> >have implications for other sessions as well, which is not the case
> >(unless all sessions are shared). For example, if you have Chrome,
> >Firefox, and Internet Exploder all active, the sessions should be
> >different, if even from the very same computer. However, multiple
> >tabs in the same browser will generally be the same session (unless
> >it's something like Chrome's Incognito feature).
> >
> >--
> ></Daniel P. Brown>
> >Network Infrastructure Manager
> >http://www.php.net/
> =========
> Thanks.
>
> >Multiple tabs in the same browser will generally be the same session.
>
> That is what I have.
>
> Ethan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
If they're all in the same browser, then what distinguishes them from
one another? If you could use that and add some sort of array in the
session with entries bearing to what tabs you have open then you could
use that to 'close' sessions. Why do you need multiple tabs open to the
same site anyway, maybe if you explained what it is you're trying to
achieve, we might help with a better way?
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Thu, Mar 31, 2011 at 13:54, Ethan Rosenberg <eth...@earthlink.net> wrote:
>
> That is what I have.
So now the guessing game begins, I suppose, right?
What happened to rephrasing the original question, Ethan? ;-P
(And why did you send me a link to your copy of WinZip?)
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
At 02:12 PM 3/31/2011, Ashley Sheridan wrote:
On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:
> At 01:30 PM 3/31/2011, Daniel Brown wrote:
> >On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg
<eth...@earthlink.net> wrote:
> > > Dear List -
> > >
> > > Thanks for your help.
> > >
> > > How do I close a session form the terminal? I need the
ability to do this
> > > for debugging. I often have more than one session open at the
> > same time, so
> > > creating a program with session_start() and session_unset() or
> > > session_destoy() would probably not work.
> >
> > Can you rephrase the question, Ethan, or give more details? From
> >the way it sounds, you're concerned that destroying a session will
> >have implications for other sessions as well, which is not the case
> >(unless all sessions are shared). For example, if you have Chrome,
> >Firefox, and Internet Exploder all active, the sessions should be
> >different, if even from the very same computer. However, multiple
> >tabs in the same browser will generally be the same session (unless
> >it's something like Chrome's Incognito feature).
> >
> >--
> ></Daniel P. Brown>
> >Network Infrastructure Manager
> >http://www.php.net/
> =========
> Thanks.
>
> >Multiple tabs in the same browser will generally be the same session.
>
> That is what I have.
>
> Ethan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
If they're all in the same browser, then what distinguishes them from
one another? If you could use that and add some sort of array in the
session with entries bearing to what tabs you have open then you could
use that to 'close' sessions. Why do you need multiple tabs open to the
same site anyway, maybe if you explained what it is you're trying to
achieve, we might help with a better way?
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
========
Ash -
I can be working on more than one program simultaneously and have one
tab open w/ program A and another w/ program B. The site in
reference is "http://localhost...."
I hope this helps.
Ethan
MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
--- End Message ---
--- Begin Message ---
On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg <eth...@earthlink.net> wrote:
>
> ========
> Ash -
>
> I can be working on more than one program simultaneously and have one tab
> open w/ program A and another w/ program B. The site in reference is
> "http://localhost...."
>
> I hope this helps.
Ah, but running on the same domain, the session will be common.
Right. Killing a session will kill it in both programs, as you
already know, but there's no native way to do one for one
[file|directory]. Your best bet, if at all possible, is to separate
by subdomains (which you can do on localhost, too, by modifying your
hosts file to alias like so:
127.0.0.1 localhost development subdomain.development
Don't worry about it being an FQDN. Prior to checking with the
router or DNS servers, all modern systems check the hosts file. Then
just add a reference to each in your Apache configuration file and
restart Apache. Boom. Done.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Thu, 2011-03-31 at 16:40 -0400, Ethan Rosenberg wrote:
> At 02:12 PM 3/31/2011, Ashley Sheridan wrote:
> >On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:
> >
> > > At 01:30 PM 3/31/2011, Daniel Brown wrote:
> > > >On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg
> > <eth...@earthlink.net> wrote:
> > > > > Dear List -
> > > > >
> > > > > Thanks for your help.
> > > > >
> > > > > How do I close a session form the terminal? I need the
> > ability to do this
> > > > > for debugging. I often have more than one session open at the
> > > > same time, so
> > > > > creating a program with session_start() and session_unset() or
> > > > > session_destoy() would probably not work.
> > > >
> > > > Can you rephrase the question, Ethan, or give more details? From
> > > >the way it sounds, you're concerned that destroying a session will
> > > >have implications for other sessions as well, which is not the case
> > > >(unless all sessions are shared). For example, if you have Chrome,
> > > >Firefox, and Internet Exploder all active, the sessions should be
> > > >different, if even from the very same computer. However, multiple
> > > >tabs in the same browser will generally be the same session (unless
> > > >it's something like Chrome's Incognito feature).
> > > >
> > > >--
> > > ></Daniel P. Brown>
> > > >Network Infrastructure Manager
> > > >http://www.php.net/
> > > =========
> > > Thanks.
> > >
> > > >Multiple tabs in the same browser will generally be the same session.
> > >
> > > That is what I have.
> > >
> > > Ethan
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >If they're all in the same browser, then what distinguishes them from
> >one another? If you could use that and add some sort of array in the
> >session with entries bearing to what tabs you have open then you could
> >use that to 'close' sessions. Why do you need multiple tabs open to the
> >same site anyway, maybe if you explained what it is you're trying to
> >achieve, we might help with a better way?
> >
> >--
> >Thanks,
> >Ash
> >http://www.ashleysheridan.co.uk
>
> ========
> Ash -
>
> I can be working on more than one program simultaneously and have one
> tab open w/ program A and another w/ program B. The site in
> reference is "http://localhost...."
>
> I hope this helps.
>
> Ethan
>
>
> MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
>
>
>
I had this problem quite a lot, so now I use sub-arrays for each site.
For example:
$_SESSION['personal_website'] = session data;
$_SESSION['friends_site'] = session data;
$_SESSION['shop_down_the_road'] = session data;
Then you need only unset the specific array for that site, rather than
the whole session.
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Thu, 2011-03-31 at 16:51 -0400, Daniel Brown wrote:
> On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg <eth...@earthlink.net> wrote:
> >
> > ========
> > Ash -
> >
> > I can be working on more than one program simultaneously and have one tab
> > open w/ program A and another w/ program B. The site in reference is
> > "http://localhost...."
> >
> > I hope this helps.
>
> Ah, but running on the same domain, the session will be common.
> Right. Killing a session will kill it in both programs, as you
> already know, but there's no native way to do one for one
> [file|directory]. Your best bet, if at all possible, is to separate
> by subdomains (which you can do on localhost, too, by modifying your
> hosts file to alias like so:
>
> 127.0.0.1 localhost development subdomain.development
>
> Don't worry about it being an FQDN. Prior to checking with the
> router or DNS servers, all modern systems check the hosts file. Then
> just add a reference to each in your Apache configuration file and
> restart Apache. Boom. Done.
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
Can you not "NAME" the sessions? and kill/destory the named session?
--- End Message ---
--- Begin Message ---
On Thursday, 31 March 2011 at 21:53, Ashley Sheridan wrote:
On Thu, 2011-03-31 at 16:40 -0400, Ethan Rosenberg wrote:
>
> > At 02:12 PM 3/31/2011, Ashley Sheridan wrote:
> > > On Thu, 2011-03-31 at 13:54 -0400, Ethan Rosenberg wrote:
> > >
> > > > At 01:30 PM 3/31/2011, Daniel Brown wrote:
> > > > > On Thu, Mar 31, 2011 at 13:09, Ethan Rosenberg
> > > <eth...@earthlink.net> wrote:
> > > > > > Dear List -
> > > > > >
> > > > > > Thanks for your help.
> > > > > >
> > > > > > How do I close a session form the terminal? I need the
> > > ability to do this
> > > > > > for debugging. I often have more than one session open at the
> > > > > same time, so
> > > > > > creating a program with session_start() and session_unset() or
> > > > > > session_destoy() would probably not work.
> > > > >
> > > > > Can you rephrase the question, Ethan, or give more details? From
> > > > > the way it sounds, you're concerned that destroying a session will
> > > > > have implications for other sessions as well, which is not the case
> > > > > (unless all sessions are shared). For example, if you have Chrome,
> > > > > Firefox, and Internet Exploder all active, the sessions should be
> > > > > different, if even from the very same computer. However, multiple
> > > > > tabs in the same browser will generally be the same session (unless
> > > > > it's something like Chrome's Incognito feature).
> > > > >
> > > > > --
> > > > > </Daniel P. Brown>
> > > > > Network Infrastructure Manager
> > > > > http://www.php.net/
> > > > =========
> > > > Thanks.
> > > >
> > > > > Multiple tabs in the same browser will generally be the same session.
> > > >
> > > > That is what I have.
> > > >
> > > > Ethan
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > > If they're all in the same browser, then what distinguishes them from
> > > one another? If you could use that and add some sort of array in the
> > > session with entries bearing to what tabs you have open then you could
> > > use that to 'close' sessions. Why do you need multiple tabs open to the
> > > same site anyway, maybe if you explained what it is you're trying to
> > > achieve, we might help with a better way?
> > >
> > > --
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> >
> > ========
> > Ash -
> >
> > I can be working on more than one program simultaneously and have one
> > tab open w/ program A and another w/ program B. The site in
> > reference is "http://localhost...."
> >
> > I hope this helps.
> >
> > Ethan
> >
> >
> > MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
>
>
> I had this problem quite a lot, so now I use sub-arrays for each site.
> For example:
>
> $_SESSION['personal_website'] = session data;
> $_SESSION['friends_site'] = session data;
> $_SESSION['shop_down_the_road'] = session data;
>
> Then you need only unset the specific array for that site, rather than
> the whole session.
Another option is to use http://php.net/session-set-cookie-params to set the
path for which the session cookie is valid.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
At 05:37 PM 3/31/2011, Ethan Rosenberg wrote:
At 04:51 PM 3/31/2011, Daniel Brown wrote:
On Thu, Mar 31, 2011 at 16:40, Ethan Rosenberg <eth...@earthlink.net> wrote:
>
> ========
> Ash -
>
> I can be working on more than one program simultaneously and have one tab
> open w/ program A and another w/ program B. The site in reference is
> "http://localhost...."
>
> I hope this helps.
Ah, but running on the same domain, the session will be common.
Right. Killing a session will kill it in both programs, as you
already know, but there's no native way to do one for one
[file|directory]. Your best bet, if at all possible, is to separate
by subdomains (which you can do on localhost, too, by modifying your
hosts file to alias like so:
127.0.0.1 localhost development subdomain.development
Don't worry about it being an FQDN. Prior to checking with the
router or DNS servers, all modern systems check the hosts file. Then
just add a reference to each in your Apache configuration file and
restart Apache. Boom. Done.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
=========
Dan -
Thanks.
Two questions:
1] What is the URL for the sub domain?
2] How do kill a session from the command line?
Ethan
--- End Message ---
--- Begin Message ---
<snip>
127.0.0.1 localhost development subdomain.development
Don't worry about it being an FQDN. Prior to checking with the
router or DNS servers, all modern systems check the hosts file. Then
just add a reference to each in your Apache configuration file and
restart Apache. Boom. Done.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
=========
Dan -
I'm a newbie...
1] What should the line in the Apache configuration file be? Just to
be sure, the file is: /etc/apache2/apache2.conf, correct?
2] Back to the original question....how do I kill a session from the terminal?
Thanks.
Ethan
--- End Message ---
--- Begin Message ---
Why not just create a no named function in the top of the class. This this way
it loads on include.
Richard Buskirk
Sent from my iPhone
On Mar 31, 2011, at 12:56 AM, "D. Dante Lorenso" <da...@lorenso.com> wrote:
> All,
>
> I want to build a config file class that gets called statically. Is there
> such a thing as a static constructor? Example:
>
> class Daz_Config {
> public static function load() {
> ...
> }
> public static function get($key) {
> self :: load();
> ...
> }
> }
>
> Daz_Config :: get('myvalue');
>
> I want to call the load function when the class is used for the first time.
> If no code ever calls "Daz_Config :: get(...)" then I never want to invoke
> load() but if it does get called, I only want to call load() once before the
> class is used further.
>
> Anyone know how to do this with calling load() at the top of all the other
> functions and writing a load() function that exits early if already loaded?
>
> -- Dante
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
On 3/25/2011 12:09 PM, markb wrote:
Very rusty with PHP.
We moved our web site to a new hosting service (godaddy). PHP changed
from 4x to 5.2.17.
I can no longer change $_SESSION variables after the first use.
First call to form - start session create variables
Second call - can read variables, change existing ones (but they do not
persist to next call) - cannot create new variable without an error
Using $_SESSION['varname'] always
session.auto_start off
register_globals off
session.use_only_cookies off
I assume this is setting difference but I can't seem to find it.
OK. found the issue.
ini_set('session.cookie_secure',true);
Causes the issue IF I don't use https. Make sense I suppose.
--
Mark B
--- End Message ---
--- Begin Message ---
Hello,
We are migrating our MySQL database from 5.0.x to 5.5.x and I have noticed that
the current PHP 4.4.x we have will not be compatible with the MySQL 5.5.x.. It
has the Client API version for MySQL 5.0.x
Unfortunately at this point, we cannot use PHP 5.3.x because of some old
application create on PHP 4.4.x. Therefore, I am looking to see if someone has
tried the PHP 5.2.x with MySQL 5.5.x and hear the experiences they have.
Our servers run Linux and our development workstations are Mac OS X 10.6.7
(Snow Leopard).
Has anyone tried to use the MySQL 5.5.x. with PHP 5.2.x, specially on Mac OS X?
Thanks,
Andre
--
Andre Matos
andrema...@mineirinho.org
--- End Message ---
--- Begin Message ---
Dear List -
Thank you for your help in the past. This an update on my session
problems.
Here is a simple test program. It never increments the session counter;
ie, does not detect that $_SESSION has been set.
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<body>
<?php
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?>
</body>
</html>
I have no idea what is wrong.
I need to make my session variables work so that I can finish a project.
Help and advice, please.
Ethan Rosenberg
MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
I tried your code on my testing computer (PHP 5.2.14) and everything works
fine. $_SESSION['views'] is counting up correctly. Maybe a problem with your
configuration?
Beste regards.
Steven
--- End Message ---