RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

2009-08-21 Thread Leon du Plessis
Hi Jamie. 

Thanks. Good info. I knew something changed somewhere. This works like a
charm in IE8..never saw the New Session option under file...me bad !!

Greetings.


-Original Message-
From: Jaime Bozza [mailto:jbo...@mindsites.com] 
Sent: 20 August 2009 09:49 PM
To: Leon du Plessis; 'Floyd Resler'
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

Leon,

This is really just a function of the browser.   When a session cookie is
created, if the browser is setup for a single instance, that's the session
cookie it'll use for *any* request to that domain.  This functions
differently depending on what browser you're using.

For example:
Firefox - All windows, tabs, etc, under the same profile will use the same
session.   If you create profiles, you can have different sessions.
IE7, IE6 - All tabs or windows opened from clicks will share the same
instance/session.  Starting IE from the icon will open up a new
instance/session.  This worked great if you wanted to run two different
sessions at the same site/domain.  Just start IE up from the icon again and
you'd have a new session.
IE8 - IE8 model changed, so that all browser windows, tabs, etc., run under
the same frame/session, much like Firefox.  Clicking the IE icon again now
just keeps the same frame and thus the same session.  Originally, this
sounded like a big problem, but IE8 introduced a new feature - File Menu -
New Session.   This will open up a new window that will be a separate frame
that will not use current session cookies.

Here's just one of many links, but gives some helpful hints on the IE side:
http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-a
nd-ie8.aspx

And another:
http://blogs.msdn.com/askie/archive/2009/05/08/session-management-within-int
ernet-explorer-8-0.aspx

One of the issues now is that if you close IE, your session does not
disappear.  In the past (IE7/IE6), your session would disappear if you
closed a browser window that you opened yourself, but it *wouldn't*
disappear if you closed a browser window that was opened by a click from
Outlook or another program.  This was a bit inconsistent.  I won't argue
whether or not their fix was the best way to go, but now it's at least
consistent.

Note - In Firefox, not even Private Browsing separates the session
cookies.  If you start Private Browsing (Firefox 3.5), log into a site, then
start a new browser window from the icon (that isn't in Private Browsing
mode), it shares the session cookies. (Before you ask, I just checked this
to be sure.)

IE8 InPrivate Mode is a totally separate session, cookies and all.  This
could possibly be another way for you to run multiple sessions against the
same domain.  OTOH, multiple InPrivate sessions running at the same time
share the same frame, so they share the same session, so it would only be
good for a single new session.  If you need more, just use File - New
Session.

Jaime 


 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com]
 Sent: Thursday, August 20, 2009 8:16 AM
 To: 'Floyd Resler'
 Cc: a...@dotcontent.net; php-general@lists.php.net
 Subject: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
 
 It is just strange that I have this condition now...maybe I missed it
 a
 year ago ?
 
  Having a different session start up for each window for tab would
 be a
 major pain.
 
 Why?
 
 People must please try and understand what I mean by NEW. It does not
 apply
 to windows/tabs being opened from a link or request.
 
 Imho, keeping the session per domain sounds wrong, it does not mean
 it is.
 It would have been nice if:
 
 Browser/tab one - my login detail container A.
 Browser/tab two - my admin login container B.
 (tabs/windows opened from browser one, then inherits container A
 naturally)
 (Closing browser one, then destroys container A then naturally only)
 
 NOT
 
 Domain.com - one session container only.
 
 Heck, I am surprised it works that way at all cause it sounds like
 the
 domain can then only handle one user a time if arrays are not used or
 profiles not created on FF no matter where the request come from, but,
 then
 I am obviously missing something in this respect as stated. When I have
 time
 I will reconstruct this concept again.
 
 Thanks anyway guys. I received some helpful advise for future
 reference.
 
 But please..I do not, like many others, want to start a war. I am ok
 with
 things how they are. We can put this thing to rest.
 
 -Original Message-
 From: Floyd Resler [mailto:fres...@adex-intl.com]
 Sent: 20 August 2009 02:25 PM
 To: Leon du Plessis
 Cc: a...@dotcontent.net; php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 Leon,
   Sessions are used on a per-domain basis.  So, no matter how many
 windows or tabs you have open for mydomain.com it will be the same
 session for all.  Having a different session start up for each window
 or tab would be a major

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis

Since we are on the subject: I have the following similar problem:

When testing page on internet explorer, I find that one tab's variables can
affect another tab's variables. Thus when having the same web-site open and
using SESSION variables but for different users, Internet explorer can
become disorientated. This also sometimes happen when I have two
separate browsing windows open with Internet Explorer for the same site.

I have yet to determine if this is an internet explorer, or PHP or
combination of the two that is causing this condition. 

To my understanding _SESSION variables should be maintained per session, tab
or window. If this has been addressed already, my apologies, but thought it
worthwhile to mention.  

If someone perhaps have a solution or can confirm this as a known issue and
maybe is the same or related to Angelo's problem?


-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 08:53 AM
To: 'Ben Dunlap'
Cc: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes



-Original Message-
From: Ben Dunlap [mailto:bdun...@agentintellect.com] 
Sent: 19 August 2009 08:18 PM
To: Angelo Zanetti
Cc: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

 We have a server with a site that does some XML calls. After lots of
testing
 I have found that the server is losing session variables.
[8]
 Also the site goes from HTTP to HTTPS at some point but this isn't the
issue
 as it loses the sessions as soon as they are set sometimes.

 Therefore I would like to know what I could check. I have read in other

Can you clarify what you mean by losing sessions? Have you taken a
network trace to see whether the client is consistently sending the
session ID with every request?

When the problem happens, is $_SESSION completely empty or is it only
missing some variables? Does it seem to happen on any page, or only
certain ones?

Thanks,

Ben


Hi Ben, 

When the problem happens the $_SESSION is partially empty. It only has the
some of the variables set.

It happens on a certain page only, but the strange thing is that it never
happened before its only happening now. But the code hasn't changed so is it
safe to assume that it's a server issue?

Thanks
Angelo

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


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


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
 It's not an issue, it's a feature.

Thanks Arno...but it is a pain also.
If I work with user A in Tab1 (window1), I want to work with user B
separately in Tab2. When user in Tab2 logs off, I still want user A to work,
and not suddenly have to re-login. Same with bank. If I work with my company
account, then my personal account must not become an issue because I am on
the same machine and site. 

I have no issue with using FF and IE to do testing as that takes care of
browser compatibility testing at the same time :-), but I think when you
start a new session with new values, it should be kept under that window/tab
alone. Cookies can take care of more details, but my opinion is data should
never be affected across windows/tabs unless the same user is logged in on
botheven then I would expect PHP to keep data per session. Maybe it goes
beyond being an IE or FF issue..the questiojn is...will PHP allow variables
from session A become corrupted when session B is in progress when they
should actually be handled seperately?

In the end I think it is something I do wrong in PHP with the SESSION
variables and how I clear themif so...I don't think PHP should allow
clearing SESSION variables from other sessions.
 
-Original Message-
From: Arno Kuhl [mailto:ak...@telkomsa.net] 
Sent: 20 August 2009 10:03 AM
To: 'Leon du Plessis'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 09:44 AM
To: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Since we are on the subject: I have the following similar problem:

When testing page on internet explorer, I find that one tab's variables can
affect another tab's variables. Thus when having the same web-site open and
using SESSION variables but for different users, Internet explorer can
become disorientated. This also sometimes happen when I have two
separate browsing windows open with Internet Explorer for the same site.

I have yet to determine if this is an internet explorer, or PHP or
combination of the two that is causing this condition. 

To my understanding _SESSION variables should be maintained per session, tab
or window. If this has been addressed already, my apologies, but thought it
worthwhile to mention.  

If someone perhaps have a solution or can confirm this as a known issue and
maybe is the same or related to Angelo's problem?



If different browser windows/tabs on the same client-side computer didn't
share session info then you'd get the effect of being able to log onto a
site with one browser window, but find in a second browser window that you
were not yet logged on. Experience will tell you that you're logged on in
both browser windows (try it with your online bank). It's not an issue, it's
a feature. If you want to be able to use different browser windows as though
they were different users then use different browsers e.g. IE and FF on the
same client-side computer will look like two separate end users to the
server, and they don't share session info or cookies.

Cheers
Arno


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


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
 It'd make sense for things to run this way, I think.  After all, I'd
find it quite confusing if I log into Google Docs, open a document (by
default, it opens in a new tab) and I had to log in yet again to be able to
edit it.

Yes. I agree. But in this case the Tab being opened is used with the same
authentication details either via POST, GET or Cookie variables. The problem
comes in when a totally different set of login credentials are being used
(for the same tab/window).  Other user's login particulars should not affect
your login variables.

-Original Message-
From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
Sent: 20 August 2009 10:40 AM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
 
 Since we are on the subject: I have the following similar problem:
 
 When testing page on internet explorer, I find that one tab's variables
can
 affect another tab's variables. Thus when having the same web-site open
and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same site.
 
 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition. 
 
 To my understanding _SESSION variables should be maintained per session,
tab
 or window. If this has been addressed already, my apologies, but thought
it
 worthwhile to mention.  
 

I'm a total newbie when it comes to these issues, but it seems to me
that Firefox behaves in the very same manner.  It's not limited to PHP
sessions either.  It's always been my experience on any website that
requires authentication, including the likes of Google Mail, etc.  When
I want to run multiple sessions for different GMail accounts, for
example, I just create a different user profile in Firefox. 

It'd make sense for things to run this way, I think.  After all, I'd
find it quite confusing if I log into Google Docs, open a document (by
default, it opens in a new tab) and I had to log in yet again to be able
to edit it.  


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


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis


That is how I know browsers to work, yet for a while the bahaviour has
changed. The question in light of this then is, should a new browser or tab
not open a new PHP SESSION ID. Session ID's should be kept if called from
existing pages or ID's? But new pages has no parent? Just wondering.

-Original Message-
From: Peter Ford [mailto:p...@justcroft.com] 
Sent: 20 August 2009 10:47 AM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

Leon du Plessis wrote:
  It's not an issue, it's a feature.
 
 Thanks Arno...but it is a pain also.
 If I work with user A in Tab1 (window1), I want to work with user B
 separately in Tab2. When user in Tab2 logs off, I still want user A to
work,
 and not suddenly have to re-login. Same with bank. If I work with my
company
 account, then my personal account must not become an issue because I am on
 the same machine and site. 
 
 I have no issue with using FF and IE to do testing as that takes care of
 browser compatibility testing at the same time :-), but I think when you
 start a new session with new values, it should be kept under that
window/tab
 alone. Cookies can take care of more details, but my opinion is data
should
 never be affected across windows/tabs unless the same user is logged in on
 botheven then I would expect PHP to keep data per session. Maybe it
goes
 beyond being an IE or FF issue..the questiojn is...will PHP allow
variables
 from session A become corrupted when session B is in progress when they
 should actually be handled seperately?
 
 In the end I think it is something I do wrong in PHP with the SESSION
 variables and how I clear themif so...I don't think PHP should allow
 clearing SESSION variables from other sessions.
  
 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net] 
 Sent: 20 August 2009 10:03 AM
 To: 'Leon du Plessis'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com] 
 Sent: 20 August 2009 09:44 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 Since we are on the subject: I have the following similar problem:
 
 When testing page on internet explorer, I find that one tab's variables
can
 affect another tab's variables. Thus when having the same web-site open
and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same site.
 
 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition. 
 
 To my understanding _SESSION variables should be maintained per session,
tab
 or window. If this has been addressed already, my apologies, but thought
it
 worthwhile to mention.  
 
 If someone perhaps have a solution or can confirm this as a known issue
and
 maybe is the same or related to Angelo's problem?
 
 
 
 If different browser windows/tabs on the same client-side computer didn't
 share session info then you'd get the effect of being able to log onto a
 site with one browser window, but find in a second browser window that you
 were not yet logged on. Experience will tell you that you're logged on in
 both browser windows (try it with your online bank). It's not an issue,
it's
 a feature. If you want to be able to use different browser windows as
though
 they were different users then use different browsers e.g. IE and FF on
the
 same client-side computer will look like two separate end users to the
 server, and they don't share session info or cookies.
 
 Cheers
 Arno
 
 

The key thing is that both tabs (or windows) from the same browser are in
the
*same* session - they send the *same* PHPID cookie. PHP is essentially
stateless
- it doesn't care where the request comes from, and ties a session to the
PHPID
cookie if it gets one. As far as PHP knows, requests from different tabs
with
the same PHPID cookie are requests from the same place in the same session.

To get a different session you need a different instance of the browser -
that's
the way browsers have been coded to work. It's not too hard with Firefox,
since
you can set up multiple profiles to have independent Firefox windows on the
same
screen.

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Hi, 

Just a re-iteration on the problem:

Browser 1 has user A details 

Browser 2 has user B details

User B logs off, then user A is suddenly in logged of status also.

The method used to destroy the session is:
// Unset all of the session variables.
$_SESSION = array();

// Finally, destroy the session.
session_destroy();

Problem. User's A session is also destroyed. The concern is, that this
should not be the case. User A must happily continue to work.

So, should PHP destroy the whole browser's session id's variables? My answer
is No.

User A and user B should have different session ids, if not, then it is
wrong. A new window should have PHP to spawn a new session id (that is, the
request does not come from an existing page where an id has been created
already. If the ids are different, then session_destroy should only clear
variables for relevant session_id, ie only User B's details In this example.


The problem then probably lies in the session_ids being either the same for
the two different logins (although they are on different browser) or
session_destroy clearing data across sessions. (I will test that later). It
would then seem that session ids is setup per location/machine by MS Windows
as per Peter's explanation. Setting up profiles is the the resolution as
suggested. Otherwise, it would be nice if Windows/IE/FF/PHP could identify
when a BRAND NEW page is being opened and then create a brand new session id
for that window/tab.

It is not a huge issue, I was just wondering if someone else had the same
annoying condition. I am happy with the responses and the functionality
somewhere on a wish-list. 

Now Back to Angelo's SESSION problem which sounded like it could be related.

Greetings!
Leon

-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 10:57 AM
To: 'Peter Ford'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes



That is how I know browsers to work, yet for a while the bahaviour has
changed. The question in light of this then is, should a new browser or tab
not open a new PHP SESSION ID. Session ID's should be kept if called from
existing pages or ID's? But new pages has no parent? Just wondering.

-Original Message-
From: Peter Ford [mailto:p...@justcroft.com] 
Sent: 20 August 2009 10:47 AM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

Leon du Plessis wrote:
  It's not an issue, it's a feature.
 
 Thanks Arno...but it is a pain also.
 If I work with user A in Tab1 (window1), I want to work with user B
 separately in Tab2. When user in Tab2 logs off, I still want user A to
work,
 and not suddenly have to re-login. Same with bank. If I work with my
company
 account, then my personal account must not become an issue because I am on
 the same machine and site. 
 
 I have no issue with using FF and IE to do testing as that takes care of
 browser compatibility testing at the same time :-), but I think when you
 start a new session with new values, it should be kept under that
window/tab
 alone. Cookies can take care of more details, but my opinion is data
should
 never be affected across windows/tabs unless the same user is logged in on
 botheven then I would expect PHP to keep data per session. Maybe it
goes
 beyond being an IE or FF issue..the questiojn is...will PHP allow
variables
 from session A become corrupted when session B is in progress when they
 should actually be handled seperately?
 
 In the end I think it is something I do wrong in PHP with the SESSION
 variables and how I clear themif so...I don't think PHP should allow
 clearing SESSION variables from other sessions.
  
 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net] 
 Sent: 20 August 2009 10:03 AM
 To: 'Leon du Plessis'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com] 
 Sent: 20 August 2009 09:44 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 Since we are on the subject: I have the following similar problem:
 
 When testing page on internet explorer, I find that one tab's variables
can
 affect another tab's variables. Thus when having the same web-site open
and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same site.
 
 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition. 
 
 To my understanding _SESSION variables should be maintained per session,
tab
 or window. If this has been addressed already, my apologies, but thought
it
 worthwhile to mention.  
 
 If someone perhaps have a solution or can confirm this as a known issue
and
 maybe is the same or related to Angelo's problem?
 
 
 
 If different browser windows

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Thanks Ashley, 

I just want to iterate again that when a new page is opened by another
existing page in a new browser or Tab, the session_id is already created and
therefore the current way browsers work is in no way compremised. The new
browser/tab would receive the session id along with GET or POST variables.

What I am suggesting/hoping is that when a new browser is opened or a new
tab is opened via the application, the protocols would reckognize that this
is the first time the page is served and is not being called from another
page. That is, a new page is loaded by the user entering it, and NOT by
clicking login or some other link from an existing page.

Yes, I know..that creates other scenarios, so is happy to not meddle with
the way browsers work. It is just a limitation I will live with and can get
by with it.

Regards
Leon

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 11:39 AM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
  It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
to
 edit it.
 
 Yes. I agree. But in this case the Tab being opened is used with the same
 authentication details either via POST, GET or Cookie variables. The
problem
 comes in when a totally different set of login credentials are being used
 (for the same tab/window).  Other user's login particulars should not
affect
 your login variables.
 
 -Original Message-
 From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
 Sent: 20 August 2009 10:40 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
  
  Since we are on the subject: I have the following similar problem:
  
  When testing page on internet explorer, I find that one tab's variables
 can
  affect another tab's variables. Thus when having the same web-site open
 and
  using SESSION variables but for different users, Internet explorer can
  become disorientated. This also sometimes happen when I have two
  separate browsing windows open with Internet Explorer for the same site.
  
  I have yet to determine if this is an internet explorer, or PHP or
  combination of the two that is causing this condition. 
  
  To my understanding _SESSION variables should be maintained per session,
 tab
  or window. If this has been addressed already, my apologies, but thought
 it
  worthwhile to mention.  
  
 
 I'm a total newbie when it comes to these issues, but it seems to me
 that Firefox behaves in the very same manner.  It's not limited to PHP
 sessions either.  It's always been my experience on any website that
 requires authentication, including the likes of Google Mail, etc.  When
 I want to run multiple sessions for different GMail accounts, for
 example, I just create a different user profile in Firefox. 
 
 It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
 to edit it.  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
The point is you are misunderstanding how browsers work. What the server
app is seeing is a new login that replaces the first. This is the way
browsers work, and if it changed to the idea you have for it, then
millions of sites would suddenly fail to work; i.e. any site that
requires a new tab or window to be opened in order to function, like
banks, etc.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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


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



RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Thanks Ashley. Will implement if the need arise again..
By limitation I actually meant annoyance. 
Limitation was the wrong word to use.
(I think all browsers has something great and something not so great)

:-)
Greetings

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 12:05 PM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 12:04 +0200, Leon du Plessis wrote:
 Thanks Ashley, 
 
 I just want to iterate again that when a new page is opened by another
 existing page in a new browser or Tab, the session_id is already created
and
 therefore the current way browsers work is in no way compremised. The new
 browser/tab would receive the session id along with GET or POST variables.
 
 What I am suggesting/hoping is that when a new browser is opened or a new
 tab is opened via the application, the protocols would reckognize that
this
 is the first time the page is served and is not being called from another
 page. That is, a new page is loaded by the user entering it, and NOT by
 clicking login or some other link from an existing page.
 
 Yes, I know..that creates other scenarios, so is happy to not meddle with
 the way browsers work. It is just a limitation I will live with and can
get
 by with it.
 
 Regards
 Leon
 
 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Sent: 20 August 2009 11:39 AM
 To: Leon du Plessis
 Cc: 'Nitebirdz'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes
 
 On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
   It'd make sense for things to run this way, I think.  After all, I'd
  find it quite confusing if I log into Google Docs, open a document (by
  default, it opens in a new tab) and I had to log in yet again to be able
 to
  edit it.
  
  Yes. I agree. But in this case the Tab being opened is used with the
same
  authentication details either via POST, GET or Cookie variables. The
 problem
  comes in when a totally different set of login credentials are being
used
  (for the same tab/window).  Other user's login particulars should not
 affect
  your login variables.
  
  -Original Message-
  From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
  Sent: 20 August 2009 10:40 AM
  To: php-general@lists.php.net
  Subject: Re: [PHP] SESSIONS lost sometimes
  
  On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
   
   Since we are on the subject: I have the following similar problem:
   
   When testing page on internet explorer, I find that one tab's
variables
  can
   affect another tab's variables. Thus when having the same web-site
open
  and
   using SESSION variables but for different users, Internet explorer can
   become disorientated. This also sometimes happen when I have two
   separate browsing windows open with Internet Explorer for the same
site.
   
   I have yet to determine if this is an internet explorer, or PHP or
   combination of the two that is causing this condition. 
   
   To my understanding _SESSION variables should be maintained per
session,
  tab
   or window. If this has been addressed already, my apologies, but
thought
  it
   worthwhile to mention.  
   
  
  I'm a total newbie when it comes to these issues, but it seems to me
  that Firefox behaves in the very same manner.  It's not limited to PHP
  sessions either.  It's always been my experience on any website that
  requires authentication, including the likes of Google Mail, etc.  When
  I want to run multiple sessions for different GMail accounts, for
  example, I just create a different user profile in Firefox. 
  
  It'd make sense for things to run this way, I think.  After all, I'd
  find it quite confusing if I log into Google Docs, open a document (by
  default, it opens in a new tab) and I had to log in yet again to be able
  to edit it.  
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 The point is you are misunderstanding how browsers work. What the server
 app is seeing is a new login that replaces the first. This is the way
 browsers work, and if it changed to the idea you have for it, then
 millions of sites would suddenly fail to work; i.e. any site that
 requires a new tab or window to be opened in order to function, like
 banks, etc.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
There is one way to get around it, and that is to use arrays within your
session variables. So for example, it might look something like this:

$_SESSION['your_app_name']['username']['some_value']

This way, if the username doesn't exist, you know there is no session
for them. It's ugly

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
Hi Angelo, 

No need to be nasty and touchy. If you have done trouble to read I have
closed the discussion in a prior listing and referred back to your original
thread. thanks

-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 01:21 PM
To: 'Leon du Plessis'; a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Leon and all.

LEON you are misunderstanding how the sessions work. Also please start your
own thread and don't hijack mine.

To the rest that replied. Thanks, I am still stuck with the problem I have
asked the hosting company to check the storage capacity and also any other
issues with the SESSIONS on the server.

However if anyone has other things they think I can look at, I'd appreciate
that very much.

Thanks
Angelo
http://www.elemental.co.za


-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 12:04 PM
To: a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Thanks Ashley, 

I just want to iterate again that when a new page is opened by another
existing page in a new browser or Tab, the session_id is already created and
therefore the current way browsers work is in no way compremised. The new
browser/tab would receive the session id along with GET or POST variables.

What I am suggesting/hoping is that when a new browser is opened or a new
tab is opened via the application, the protocols would reckognize that this
is the first time the page is served and is not being called from another
page. That is, a new page is loaded by the user entering it, and NOT by
clicking login or some other link from an existing page.

Yes, I know..that creates other scenarios, so is happy to not meddle with
the way browsers work. It is just a limitation I will live with and can get
by with it.

Regards
Leon

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 11:39 AM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
  It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
to
 edit it.
 
 Yes. I agree. But in this case the Tab being opened is used with the same
 authentication details either via POST, GET or Cookie variables. The
problem
 comes in when a totally different set of login credentials are being used
 (for the same tab/window).  Other user's login particulars should not
affect
 your login variables.
 
 -Original Message-
 From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
 Sent: 20 August 2009 10:40 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
  
  Since we are on the subject: I have the following similar problem:
  
  When testing page on internet explorer, I find that one tab's variables
 can
  affect another tab's variables. Thus when having the same web-site open
 and
  using SESSION variables but for different users, Internet explorer can
  become disorientated. This also sometimes happen when I have two
  separate browsing windows open with Internet Explorer for the same site.
  
  I have yet to determine if this is an internet explorer, or PHP or
  combination of the two that is causing this condition. 
  
  To my understanding _SESSION variables should be maintained per session,
 tab
  or window. If this has been addressed already, my apologies, but thought
 it
  worthwhile to mention.  
  
 
 I'm a total newbie when it comes to these issues, but it seems to me
 that Firefox behaves in the very same manner.  It's not limited to PHP
 sessions either.  It's always been my experience on any website that
 requires authentication, including the likes of Google Mail, etc.  When
 I want to run multiple sessions for different GMail accounts, for
 example, I just create a different user profile in Firefox. 
 
 It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
 to edit it.  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
The point is you are misunderstanding how browsers work. What the server
app is seeing is a new login that replaces the first. This is the way
browsers work, and if it changed to the idea you have for it, then
millions of sites would suddenly fail to work; i.e. any site that
requires a new tab or window to be opened in order to function, like
banks, etc.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General

RE: [PHP] SESSIONS lost sometimes

2009-08-20 Thread Leon du Plessis
No problem! Thx

-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 02:35 PM
To: 'Leon du Plessis'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Leon, 

No harm intended :) Just thought that people were missing my post now and
only answering yours.

Anyways hope your issue got resolved.

Angelo


-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 01:46 PM
To: php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Angelo, 

No need to be nasty and touchy. If you have done trouble to read I have
closed the discussion in a prior listing and referred back to your original
thread. thanks

-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 20 August 2009 01:21 PM
To: 'Leon du Plessis'; a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Hi Leon and all.

LEON you are misunderstanding how the sessions work. Also please start your
own thread and don't hijack mine.

To the rest that replied. Thanks, I am still stuck with the problem I have
asked the hosting company to check the storage capacity and also any other
issues with the SESSIONS on the server.

However if anyone has other things they think I can look at, I'd appreciate
that very much.

Thanks
Angelo
http://www.elemental.co.za


-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 20 August 2009 12:04 PM
To: a...@ashleysheridan.co.uk
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

Thanks Ashley, 

I just want to iterate again that when a new page is opened by another
existing page in a new browser or Tab, the session_id is already created and
therefore the current way browsers work is in no way compremised. The new
browser/tab would receive the session id along with GET or POST variables.

What I am suggesting/hoping is that when a new browser is opened or a new
tab is opened via the application, the protocols would reckognize that this
is the first time the page is served and is not being called from another
page. That is, a new page is loaded by the user entering it, and NOT by
clicking login or some other link from an existing page.

Yes, I know..that creates other scenarios, so is happy to not meddle with
the way browsers work. It is just a limitation I will live with and can get
by with it.

Regards
Leon

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 20 August 2009 11:39 AM
To: Leon du Plessis
Cc: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes

On Thu, 2009-08-20 at 10:50 +0200, Leon du Plessis wrote:
  It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again to be able
to
 edit it.
 
 Yes. I agree. But in this case the Tab being opened is used with the same
 authentication details either via POST, GET or Cookie variables. The
problem
 comes in when a totally different set of login credentials are being used
 (for the same tab/window).  Other user's login particulars should not
affect
 your login variables.
 
 -Original Message-
 From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
 Sent: 20 August 2009 10:40 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 On Thu, Aug 20, 2009 at 09:44:02AM +0200, Leon du Plessis wrote:
  
  Since we are on the subject: I have the following similar problem:
  
  When testing page on internet explorer, I find that one tab's variables
 can
  affect another tab's variables. Thus when having the same web-site open
 and
  using SESSION variables but for different users, Internet explorer can
  become disorientated. This also sometimes happen when I have two
  separate browsing windows open with Internet Explorer for the same site.
  
  I have yet to determine if this is an internet explorer, or PHP or
  combination of the two that is causing this condition. 
  
  To my understanding _SESSION variables should be maintained per session,
 tab
  or window. If this has been addressed already, my apologies, but thought
 it
  worthwhile to mention.  
  
 
 I'm a total newbie when it comes to these issues, but it seems to me
 that Firefox behaves in the very same manner.  It's not limited to PHP
 sessions either.  It's always been my experience on any website that
 requires authentication, including the likes of Google Mail, etc.  When
 I want to run multiple sessions for different GMail accounts, for
 example, I just create a different user profile in Firefox. 
 
 It'd make sense for things to run this way, I think.  After all, I'd
 find it quite confusing if I log into Google Docs, open a document (by
 default, it opens in a new tab) and I had to log in yet again

[PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

2009-08-20 Thread Leon du Plessis
It is just strange that I have this condition now...maybe I missed it a
year ago ? 

 Having a different session start up for each window for tab would be a
major pain.

Why? 

People must please try and understand what I mean by NEW. It does not apply
to windows/tabs being opened from a link or request.

Imho, keeping the session per domain sounds wrong, it does not mean it is.
It would have been nice if:

Browser/tab one - my login detail container A.
Browser/tab two - my admin login container B.
(tabs/windows opened from browser one, then inherits container A naturally)
(Closing browser one, then destroys container A then naturally only)

NOT

Domain.com - one session container only.

Heck, I am surprised it works that way at all cause it sounds like the
domain can then only handle one user a time if arrays are not used or
profiles not created on FF no matter where the request come from, but, then
I am obviously missing something in this respect as stated. When I have time
I will reconstruct this concept again.

Thanks anyway guys. I received some helpful advise for future reference.

But please..I do not, like many others, want to start a war. I am ok with
things how they are. We can put this thing to rest.

-Original Message-
From: Floyd Resler [mailto:fres...@adex-intl.com] 
Sent: 20 August 2009 02:25 PM
To: Leon du Plessis
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

Leon,
Sessions are used on a per-domain basis.  So, no matter how many  
windows or tabs you have open for mydomain.com it will be the same  
session for all.  Having a different session start up for each window  
or tab would be a major pain.  If you needed to keep track of a user  
ID, for example, you wouldn't be able to.  As already mentioned you  
can use different browsers.  You can also set up sub-domains which  
would each have their own sessions.

Take care,
Floyd

On Aug 20, 2009, at 4:26 AM, Leon du Plessis wrote:

  It's not an issue, it's a feature.

 Thanks Arno...but it is a pain also.
 If I work with user A in Tab1 (window1), I want to work with user B
 separately in Tab2. When user in Tab2 logs off, I still want user A  
 to work,
 and not suddenly have to re-login. Same with bank. If I work with my  
 company
 account, then my personal account must not become an issue because I  
 am on
 the same machine and site.

 I have no issue with using FF and IE to do testing as that takes  
 care of
 browser compatibility testing at the same time :-), but I think when  
 you
 start a new session with new values, it should be kept under that  
 window/tab
 alone. Cookies can take care of more details, but my opinion is data  
 should
 never be affected across windows/tabs unless the same user is logged  
 in on
 botheven then I would expect PHP to keep data per session. Maybe  
 it goes
 beyond being an IE or FF issue..the questiojn is...will PHP allow  
 variables
 from session A become corrupted when session B is in progress when  
 they
 should actually be handled seperately?

 In the end I think it is something I do wrong in PHP with the SESSION
 variables and how I clear themif so...I don't think PHP should  
 allow
 clearing SESSION variables from other sessions.

 -Original Message-
 From: Arno Kuhl [mailto:ak...@telkomsa.net]
 Sent: 20 August 2009 10:03 AM
 To: 'Leon du Plessis'; php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes

 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com]
 Sent: 20 August 2009 09:44 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] SESSIONS lost sometimes

 Since we are on the subject: I have the following similar problem:

 When testing page on internet explorer, I find that one tab's  
 variables can
 affect another tab's variables. Thus when having the same web-site  
 open and
 using SESSION variables but for different users, Internet explorer can
 become disorientated. This also sometimes happen when I have two
 separate browsing windows open with Internet Explorer for the same  
 site.

 I have yet to determine if this is an internet explorer, or PHP or
 combination of the two that is causing this condition.

 To my understanding _SESSION variables should be maintained per  
 session, tab
 or window. If this has been addressed already, my apologies, but  
 thought it
 worthwhile to mention.

 If someone perhaps have a solution or can confirm this as a known  
 issue and
 maybe is the same or related to Angelo's problem?

 

 If different browser windows/tabs on the same client-side computer  
 didn't
 share session info then you'd get the effect of being able to log  
 onto a
 site with one browser window, but find in a second browser window  
 that you
 were not yet logged on. Experience will tell you that you're logged  
 on in
 both browser windows (try it with your online bank). It's not an  
 issue, it's
 a feature. If you want

RE: [PHP] what to use instead of foreach

2009-04-14 Thread Leon du Plessis
Hi PJ,

Maybe you should post your code, or portion thereof. The trained eyes on the
list will quickly gather where the problem in the logic lies. 

Maybe you can also sacrifice some of your data or data structures if not too
sensitive. This will help to validate the route you are trying to follow.

Best wishes
Leon

-Original Message-
From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] 
Sent: 14 April 2009 05:45 PM
To: PJ
Cc: Leon du Plessis; php-general@lists.php.net
Subject: Re: [PHP] what to use instead of foreach

2009/4/13 PJ af.gour...@videotron.ca:
 I have already tried with several count and for schemes. None work
 because foreach ignores any counters once in the loop. Also, this
 foreach is nested within another foreach; don't know if that affects
 anything.


Have you heard of while()? You can use it in combination with
array_pop() and count()

like:
?
while (($data = array_pop($array)) !== NULL) {
/* having $data and count($array) changes with every loop */
}
?

Bye

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


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



RE: [PHP] what to use instead of foreach

2009-04-13 Thread Leon du Plessis
Hi PJ, 

Ok, If I understand correctly you can attempt to alter your code as per
following example (I am breaking it down a little for readability):

a) If you only wish to output the authors, see also Mark Kelly's example,
You can simply output as many authors you have associated (you will need an
associated array!!:

Or b) I include the following alternative example:


$string_out = :
Foreach ($my_titles as $titles)
{
   Echo Title: $titles By:br;
   Foreach($my_authors[$title] as $author)
  $string_out .= $author, ; /* Building string */

   // Add br
   $string_out .= br;

   // Here you would replace your last comma with the  you want
   // There are a few ways to do this (like Mark Kelly's), but will try 
   // another way (older, maybe less complicated?).
   $final_string = substr($string_out,0,strrpos($string_out,,) - 1);
   $final_string .=. 
  substr($string_out,strrpos($string_out,,) + 1);
}


So all you need is to modal your data around this, and you should be fine. 
You could construct your arrays then as follows as an example:


$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone,a notherone);
$my_authors[title2] = array(mr. a,mr. b);
... 

and so forth...how you construct the data is then very important as you can
then later use it simplify your coding as you progress and as demonstrated
below:

In future, where the need justifies it, you can construct your array to
already contain the needed string you want to output, it may help, but you
will sometimes have the same effort in constructing the data for the arrays,
so it is up to you to decide which approach is going to be best: e.g.
$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone, a notherone  Mr. X);

Then you can simply echo the array value:
echo $my_authors[title1] . br;

Hope it is enough info for to work on for now!!

Have fun!
Leon

-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 13 April 2009 04:33 PM
To: Leon du Plessis
Cc: php-general@lists.php.net
Subject: Re: [PHP] what to use instead of foreach

Hi Leon,
Thanks for the suggestion; I'm quite new to all this, so it's a bit
complicated for my peanut brain.
I have already tried with several count and for schemes. None work
because foreach ignores any counters once in the loop. Also, this
foreach is nested within another foreach; don't know if that affects
anything.
I'll try to understand the second suggestion using for. I'll see what
comes up.
There are actually several conditions that have to be met:
1. if only 1 author = echo authorbr
2. if 2 authors = echo author  author1br
3. if more than 2 authors = echo author, author1, author2  author3br
That's what makes it a toughie

Leon du Plessis wrote:
 You may try something basic like:

 $b = 1;
 foreach ($my_array as $a)
 {
 echo  $a ;

 //Send new line to browser
 if ($b++ == 3) { echo br; $b = 1; }
 }

 Or there are some different ways to approach this also like:
 for ($a = current($my_array); $a; $a = next($my_array))
 {
 //Format 1
 echo  $a ;
 $a = next($my_array);

 //Format 2
 /* you may add checks here to see if $a contains data */
 echo  ~ $a ~ ; $a = next($my_array);

 //Format 3 + NEW LINE
 /* you may add checks here to see if $a contains data */
 echo  ~~ $a ~~br ;
 }

 This way you have some added control over the iteration through the array,
 and you can play around with when  how to display what.

 Regards.

 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: 12 April 2009 08:57 PM
 To: php-general@lists.php.net
 Subject: [PHP] what to use instead of foreach

 foreach does not allow for different formatting for output...
 What could be used as a workaround?
 example:
 echo $some_result, br; // will print all results in 1 column
 echo $some_result, ,; // will print all results comma-separated in 1 row

 But how do you get result1, result2  result3 // with br at end ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

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


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



RE: [PHP] what to use instead of foreach

2009-04-13 Thread Leon du Plessis
Hi PJ, 

You may want to remove the , before the br...That was a slight oversight
on my partsorry.'bout that...I will leave you to do the fixing, but I am
sure you get the general idea.

Best wishes..Leon

-Original Message-
From: Leon du Plessis [mailto:l...@dsgnit.com] 
Sent: 13 April 2009 06:48 PM
To: 'PJ'
Cc: php-general@lists.php.net
Subject: RE: [PHP] what to use instead of foreach

Hi PJ, 

Ok, If I understand correctly you can attempt to alter your code as per
following example (I am breaking it down a little for readability):

a) If you only wish to output the authors, see also Mark Kelly's example,
You can simply output as many authors you have associated (you will need an
associated array!!:

Or b) I include the following alternative example:


$string_out = :
Foreach ($my_titles as $titles)
{
   Echo Title: $titles By:br;
   Foreach($my_authors[$title] as $author)
  $string_out .= $author, ; /* Building string */

   // Add br
   $string_out .= br;

   // Here you would replace your last comma with the  you want
   // There are a few ways to do this (like Mark Kelly's), but will try 
   // another way (older, maybe less complicated?).
   $final_string = substr($string_out,0,strrpos($string_out,,) - 1);
   $final_string .=. 
  substr($string_out,strrpos($string_out,,) + 1);
}


So all you need is to modal your data around this, and you should be fine. 
You could construct your arrays then as follows as an example:


$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone,a notherone);
$my_authors[title2] = array(mr. a,mr. b);
... 

and so forth...how you construct the data is then very important as you can
then later use it simplify your coding as you progress and as demonstrated
below:

In future, where the need justifies it, you can construct your array to
already contain the needed string you want to output, it may help, but you
will sometimes have the same effort in constructing the data for the arrays,
so it is up to you to decide which approach is going to be best: e.g.
$my_titles = array(title1,title2);
$my_authors[title1] = array(a someone, a notherone  Mr. X);

Then you can simply echo the array value:
echo $my_authors[title1] . br;

Hope it is enough info for to work on for now!!

Have fun!
Leon

-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 13 April 2009 04:33 PM
To: Leon du Plessis
Cc: php-general@lists.php.net
Subject: Re: [PHP] what to use instead of foreach

Hi Leon,
Thanks for the suggestion; I'm quite new to all this, so it's a bit
complicated for my peanut brain.
I have already tried with several count and for schemes. None work
because foreach ignores any counters once in the loop. Also, this
foreach is nested within another foreach; don't know if that affects
anything.
I'll try to understand the second suggestion using for. I'll see what
comes up.
There are actually several conditions that have to be met:
1. if only 1 author = echo authorbr
2. if 2 authors = echo author  author1br
3. if more than 2 authors = echo author, author1, author2  author3br
That's what makes it a toughie

Leon du Plessis wrote:
 You may try something basic like:

 $b = 1;
 foreach ($my_array as $a)
 {
 echo  $a ;

 //Send new line to browser
 if ($b++ == 3) { echo br; $b = 1; }
 }

 Or there are some different ways to approach this also like:
 for ($a = current($my_array); $a; $a = next($my_array))
 {
 //Format 1
 echo  $a ;
 $a = next($my_array);

 //Format 2
 /* you may add checks here to see if $a contains data */
 echo  ~ $a ~ ; $a = next($my_array);

 //Format 3 + NEW LINE
 /* you may add checks here to see if $a contains data */
 echo  ~~ $a ~~br ;
 }

 This way you have some added control over the iteration through the array,
 and you can play around with when  how to display what.

 Regards.

 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: 12 April 2009 08:57 PM
 To: php-general@lists.php.net
 Subject: [PHP] what to use instead of foreach

 foreach does not allow for different formatting for output...
 What could be used as a workaround?
 example:
 echo $some_result, br; // will print all results in 1 column
 echo $some_result, ,; // will print all results comma-separated in 1 row

 But how do you get result1, result2  result3 // with br at end ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

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


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


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



RE: [PHP] what to use instead of foreach

2009-04-12 Thread Leon du Plessis
You may try something basic like:

$b = 1;
foreach ($my_array as $a)
{  
echo  $a ;

//Send new line to browser
if ($b++ == 3) { echo br; $b = 1; }
}

Or there are some different ways to approach this also like:
for ($a = current($my_array); $a; $a = next($my_array))
{  
//Format 1
echo  $a ; 
$a = next($my_array);

//Format 2
/* you may add checks here to see if $a contains data */
echo   ~ $a ~ ; $a = next($my_array);

//Format 3 + NEW LINE
/* you may add checks here to see if $a contains data */
echo   ~~ $a ~~br ;
}

This way you have some added control over the iteration through the array,
and you can play around with when  how to display what.

Regards.

-Original Message-
From: PJ [mailto:af.gour...@videotron.ca] 
Sent: 12 April 2009 08:57 PM
To: php-general@lists.php.net
Subject: [PHP] what to use instead of foreach

foreach does not allow for different formatting for output...
What could be used as a workaround?
example:
echo $some_result, br; // will print all results in 1 column
echo $some_result, ,; // will print all results comma-separated in 1 row

But how do you get result1, result2  result3 // with br at end ?

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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


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



RE: [PHP] Button id's - firefox and IE different ?

2009-04-02 Thread Leon du Plessis

Another suggestion would be to use the Input tag as suggested by Richard, 

but rename the name value ie:

input type=submit name=btid1 value=Delete /
input type=submit name=btid2 value=Delete /
input type=submit name=btid3 value=Delete /

You can then use your PHP variable $_POST[btid1], $_POST[btid2] or
$_POST[btid3], etc, to determine relevant actions.


-Original Message-
From: Angus Mann [mailto:angusm...@pobox.com] 
Sent: 02 April 2009 12:45 PM
To: Richard Heyes
Cc: php-general@lists.php.net
Subject: Re: [PHP] Button id's - firefox and IE different ?

I can do as you suggest below, but then the buttons are labelled Delete 
Cancel and Save to the user.

The essential point is that they all need to say Delete. I know I can 
accomplish this by making multiple forms, each with its own button but for 
my purpose that's a pain is the ***.

IE returns the text displayed in the button regardless of the btid value. 
It seems to just ignore it.

Firefox returns the value assigned to btid as I intended regardless of the

text in the button that the user sees.



- Original Message - 
From: Richard Heyes rich...@php.net
To: Angus Mann angusm...@pobox.com
Cc: php-general@lists.php.net
Sent: Thursday, April 02, 2009 8:17 PM
Subject: Re: [PHP] Button id's - firefox and IE different ?


 Any suggestions ?

 Try this:

 input type=submit name=btid value=Delete /
 input type=submit name=btid value=Cancel /
 input type=submit name=btid value=Save /


 And then you can check the value of $_POST['btid']. Oh and btw...
 center... seriously?
 That's so 9 years ago. ;-)

 -- 
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.net (Updated March 28th)

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

 


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


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



RE: [PHP] print a to z

2009-01-15 Thread Leon du Plessis
I used that notation before, and it did not work 100%. 
Adapt as follows:

for ($i = 'a'; $i = 'z'; $i++)
if ($i == aa) break; else echo $i;

-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: 16 January 2009 07:55 AM
To: php-general@lists.php.net
Subject: Re: [PHP] print a to z

On Thu, Jan 15, 2009 at 08:32:14PM -0800, paragasu wrote:

 i have this cute little problem. i want to print a to z for site
navigation
 my first attempt work fine
 
 for($i = '65'; $i  '91'; ++$i)
   echo chr($i);
 
 but someone point me a more interesting solutions
 
 for($i = 'a'; $i  'z'; ++$i)
   echo $i
 
 the only problem with the 2nd solutions is it only print up to Y without
z.
 so how to print up to z with the 2nd solutions? because it turn out
 that you cant to something
 like for($i = 'a'; $i = 'z'; ++$i)..

for ($i = 'a'; $i = 'z'; $i++)
echo $i;

Paul

-- 
Paul M. Foster

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


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



RE: [PHP] Little regex help please...

2008-10-13 Thread Leon du Plessis

-Original Message-
From: Ryan S [mailto:[EMAIL PROTECTED] 
Sent: 13 October 2008 07:09 PM
To: Eric Butera; Boyd, Todd M.
Cc: php php
Subject: Re: [PHP] Little regex help please...

Hey Todd, Eric,

Thanks for replying.

 I don't believe you need both the / and the # for delimiters in your
 RegEx. Try using just # (since / is actually going to be in the text
 you're searching for) like this:

 ?php
  $data =
 file_get_contents(http://www.youtube.com/watch?v=oQ2dKXGAjNg;);
  preg_match('#title([^]*)/title#iU', $data, $match);
  $title = $match[1];
  echo $title;
 ?



 You can also escape the / like \/.


Ok, I changed it to:
?php
$data = file_get_contents(http://www.youtube.com/watch?v=oQ2dKXGAjNg;);
preg_match('/#title([^]*)\/title#iU',$data,$match);
$title=$match[1]; 
echo $title;
?
And this is the error i am getting:

Warning:  preg_match() [function.preg-match]: No ending delimiter '/' found
in C:\wamp\www\ezee\tests\get_remote_title.php on line 3


 Sorry forgot to include the list in my post to you

Here is another solution if you don't want to play around too much with
regex:

?php
$data = file_get_contents(http://www.youtube.com/watch?v=oQ2dKXGAjNg;);

$strt = strpos($data,title)+7;
$end = strpos($data,/title);
$len = $end - $strt;

$title= substr($data,$strt,$len);

echo $title
?

Produces:
YouTube - REALLY funny ad

As mentioned, you can probably neaten this up a bitregex may be too
complex for the simple requirement needed ?

But for fun, it will be nice to see get if preg_match can do it at some
stage :-)

Regards,

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


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



RE: [PHP] Adding encryption to passwords

2008-09-19 Thread Leon du Plessis

You can try the MySQL built in functions. Ie encode(str, key)

insert into test (password) values (encode(mypass,some key));

You can then use the decode() functions in your matching queries. 
You also need to consider security of your php code, as the key to decode
will be in the query strings. 

There are other built-in encryptions functions in MySQL you can explore.

-Original Message-
From: Thodoris [mailto:[EMAIL PROTECTED] 
Sent: 19 September 2008 10:25 AM
To: PHP General list
Subject: [PHP] Adding encryption to passwords

Hi guys I have developed an intranet web interface with user access. 
I am storing the passwords into a mysql table as raw text (I know not so 
secure). So I am adding group access features and I am thinking to 
encrypt the passwords because this seems to grow as a project although 
it started as a simple web tool.

So  what do you think is  the best way to use crypt, mcrypt, hash or 
perhaps md5 and what are really the differences because I am not sure if 
I get it right.

-- 
Thodoris


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


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



[PHP] hash_hmac: Encoding with two different results problem

2008-07-24 Thread Leon du Plessis
hi,
I hope this is the right group for this type of problem:

I am using hash_hmac to provide me with a sha1 encoded hash string. The 
problem is as follows:

$hash = hash_hmac('sha1', 
'030B6A05696E657400C54601C60001550187360603773500018707060373796E63000187340603687474703A2F2F772E73796E632E636F6D2F73796E630001C65901873A06032E2F636F6E7461637473000187070603436F6E74616374732044420001872E0603746578742F782D7663617264000101C6570187310603757365726E616D6500018732060370617373776F72640001010101',
 
'1234');

Note: it is important the key to use during encoding id 1234 for this 
example.

Result:
eb38ffd597c6d1e01cd24a0e46dff426354510fe

Using a hash calculator from slavasoft also yields this result, which 
indicate the encoding is fine.
eb38ffd597c6d1e01cd24a0e46dff426354510fe

However, Slavasoft's calculator has an option to provide the string as Text 
or Hex.

Selecting hex yields this result:
9f9be99ea5bf5ba009af0a5c12021f420cb27652  and this is the string I 
need!!!

So either hash_hmac function needs a way to let it know the string is of 
type hexor the string itself needs to be converted. I have tried some 
conversions on the string but to no avail.
Anyone have any thoughts?



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