Re: [PHP] $_SESSION problem [NOW SOLVED]

2008-04-14 Thread Andrew Ballard
On Fri, Apr 11, 2008 at 5:34 PM, tedd [EMAIL PROTECTED] wrote:
 At 11:33 AM -0400 4/11/08, Daniel Brown wrote:

  On Fri, Apr 11, 2008 at 10:29 AM, Ford, Mike [EMAIL PROTECTED]
 wrote:
 
  
Sounds like a register_globals=On issue
  
 
 It does to me, as well.  I know, Tedd, that on the php1.net site
  that you mentioned to me off-list, I'm about 99% positive that it's
  the reason.  Shared hosts generally keep register_globals on and leave
  it up to the individual customer to turn it off.  On that particular
  server, though, since it's mostly developers, I may just send out an
  email to get feedback and turn it off at the main, and then allow
  ya'all to override it on your individual sites.
 
 The thing that makes me wonder (and I haven't checked myself to
  verify) is why two sites, on the same server, having the same
 

  Hey!

  I found it and you were right.

  On my webbytedd.com site, I had a htaccess file that read:

  AddDefaultCharset utf-8

  php_value register_globals 0
  php_value magic_quotes_gpc 0
  php_value magic_quotes_sybase 0
  php_value magic_quotes_runtime 0

  And I didn't have that htaccess file on my sperling.com site. However, what
 fooled me was in both scripts I had:

  ini_set( 'register_globals', '0' );

  So, I thought that was the same, but apparently it's not. Maybe because my
 server had safe_mode ON it won't allow it -- I don't know. Another question
 for another time.

  Thanks a bunch guys!

  Cheers,

  tedd

  PS: I did try the session_write_close and several other suggestions, but
 none worked.


The register_globals value is something that cannot be set at runtime.
If you pass it to ini_set(), it will appear to work -- you won't get
an error and successive calls to phpinfo() will show the new value;
however, by the time PHP gets far enough down the chain to execute
your ini_set() command, PHP has already determined whether it should
register global variables. The manual indicates that this wasn't
always the case, but (not knowing the internals then or now) I don't
understand how. (The table on that page says it was PHP_INI_ALL for
versions up to 4.2.3.)

http://us.php.net/manual/en/ini.core.php#ini.register-globals

Andrew

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



Re: [PHP] $_SESSION problem

2008-04-11 Thread tedd

At 5:10 PM -0600 4/10/08, Nathan Nobbe wrote:
On Thu, Apr 10, 2008 at 5:05 PM, Nathan Nobbe 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:


On Thu, Apr 10, 2008 at 4:29 PM, tedd 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:


  you might just dump out the session component of the php config on 
each site to ensure theyre the same.



on that last note, this could be useful,

?php
die(var_dump(ini_get_all('session')));
?

-nathan


They are identical -- and the same as shown in phpInfo, as I said.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

Re: [PHP] $_SESSION problem

2008-04-11 Thread tedd

At 5:05 PM -0600 4/10/08, Nathan Nobbe wrote:
On Thu, Apr 10, 2008 at 4:29 PM, tedd 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:


Hi gang:

I'm stumped and in need of some expert explanation.

I have prepared two demos (showing code) for your enjoyment:

[1] http://www.webbytedd.com/x/index.phphttp://www.webbytedd.com/x/index.php
[2] http://sperling.com/x/index.phphttp://sperling.com/x/index.php

Both of these demos have the exact same code; and are on the same 
server; with exactly the same php-info -- so, why do they behave 
differently re sessions?


Note that [1] will retain the session values throughout the entire 
session, while [2] does not and loses session values.



as a sanity check have you dumped out the contents of the session 
after writing to it on [2] ?

eg.

?php
// 
 $_SESSION['q6'] = ( isset($_SESSION['q6']) ? $_SESSION['q6'] : 0);
$_SESSION['q7'] = ( isset($_SESSION['q7']) ? $_SESSION['q7'] : 0);

$_SESSION['q8'] = ( isset($_SESSION['q8']) ? $_SESSION['q8'] : 0); 
$_SESSION['q9'] = ( isset($_SESSION['q9']) ? $_SESSION['q9'] : 0);

var_dump($_SESSION);

?
 you might just dump out the session component of the php config on 
each site to ensure theyre the same.


-nathan


Isn't that what the code is doing?

I'm dumping the results in a print_r($_SESSION) -- isn't that he same thing?

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

Re: [PHP] $_SESSION problem [SOLVED (sort-of)]

2008-04-11 Thread tedd

At 10:12 PM -0400 4/10/08, Eric Wood wrote:

tedd wrote:


[1] http://www.webbytedd.com/x/index.php
[2] http://sperling.com/x/index.php

Both of these demos have the exact same code; and are on the same 
server; with exactly the same php-info -- so, why do they behave 
differently re sessions?


Strange.  I've run into issues whenever I use variable names which 
are the same as session variables.  It's as if they step on each 
others toes.  I try to use uniq var names.  I've also recently run 
into customized 401 pages (which you may not see happen, check the 
logs) start up and the session data gets overwrite due to a lack of 
session file locking.

-eric



-eric:

You didn't provide the reason why, but you did provide a solution.

Changing the variable names to be different than the session names 
fixed the problem.


Now, if any php guru would care to tell me why, I would really like to know.

Thanks eric.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] $_SESSION problem [SOLVED (sort-of)]

2008-04-11 Thread Ford, Mike
On 11 April 2008 14:45, tedd advised:

 At 10:12 PM -0400 4/10/08, Eric Wood wrote:
 tedd wrote:
 
 [1] http://www.webbytedd.com/x/index.php
 [2] http://sperling.com/x/index.php
 
 Both of these demos have the exact same code; and are on the same
 server; with exactly the same php-info -- so, why do they behave
 differently re sessions?
 
 Strange.  I've run into issues whenever I use variable names which
 are the same as session variables.  It's as if they step on each
 others toes.  I try to use uniq var names.  I've also recently run
 into customized 401 pages (which you may not see happen, check the
 logs) start up and the session data gets overwrite due to a lack of
 session file locking. -eric
 
 
 -eric:
 
 You didn't provide the reason why, but you did provide a solution.
 
 Changing the variable names to be different than the session names
fixed
 the problem. 
 
 Now, if any php guru would care to tell me why, I would
 really like to know.

Sounds like a register_globals=On issue


 --
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] $_SESSION problem [SOLVED (sort-of)]

2008-04-11 Thread Daniel Brown
On Fri, Apr 11, 2008 at 10:29 AM, Ford, Mike [EMAIL PROTECTED] wrote:

  Sounds like a register_globals=On issue

It does to me, as well.  I know, Tedd, that on the php1.net site
that you mentioned to me off-list, I'm about 99% positive that it's
the reason.  Shared hosts generally keep register_globals on and leave
it up to the individual customer to turn it off.  On that particular
server, though, since it's mostly developers, I may just send out an
email to get feedback and turn it off at the main, and then allow
ya'all to override it on your individual sites.

The thing that makes me wonder (and I haven't checked myself to
verify) is why two sites, on the same server, having the same
phpinfo() output, would have different results.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] $_SESSION problem

2008-04-11 Thread Nathan Nobbe
On Fri, Apr 11, 2008 at 6:30 AM, tedd [EMAIL PROTECTED] wrote:

 Isn't that what the code is doing?

 I'm dumping the results in a print_r($_SESSION) -- isn't that he same
 thing?


sorry tedd; obviously i was hasty to post.  but i figured just looking for
the obvious would be a good exercise as i cant count the times ive launched
into an exhaustive search for the problem when its really something silly
ive overlooked.  that said; i know ur smart and you always post hard
problems for 'the gang' ;)
anyway, taking the cue from some of the other responses, have you looked at
the page on session_write_close() ?
http://us2.php.net/manual/en/function.session-write-close.php
its kind of interesting; it looks like lots of people have run into issues
using the location header to redirect clients to another script after a form
submission.  its never happened to me (knock on wood) but anyway some of the
posts on that page may be worth reading.
also, though it wont answer your question about why its happening, i was
thinking you might alter the flow of ur scripts to see if you can get the
same behavior on both sites.  heres what i was thinking:
add a hidden input to the form (from index.php)

input type=hidden name=formsubmission value=1 /

then after you call session_start() in index.php, have the following

if(isset($_POST['formsubmission'])  $_POST['formsubmission'] == '1')) {
include('part2.php');  // process form submission
}

then, make the following adjustments to part2.php

remove the call to session_start()
remove the call to header(location ...
remove the call to exit()

i think this will have the effect that the work flow is unaltered, but the
organization of the logic on the back end will be different.  effectively
the call to header(location... will be removed so we would be able to tell
if the issue is related to that.

-nathan


Re: [PHP] $_SESSION problem [SOLVED (sort-of)]

2008-04-11 Thread Nathan Nobbe
top posting for the hell of it;
disregard last post; i didnt see the [solved] sort-of thread.

-nathan

On Fri, Apr 11, 2008 at 7:44 AM, tedd [EMAIL PROTECTED] wrote:

 At 10:12 PM -0400 4/10/08, Eric Wood wrote:

  tedd wrote:
 
  
   [1] http://www.webbytedd.com/x/index.php
   [2] http://sperling.com/x/index.php
  
   Both of these demos have the exact same code; and are on the same
   server; with exactly the same php-info -- so, why do they behave 
   differently
   re sessions?
  
 
  Strange.  I've run into issues whenever I use variable names which are
  the same as session variables.  It's as if they step on each others toes.  I
  try to use uniq var names.  I've also recently run into customized 401 pages
  (which you may not see happen, check the logs) start up and the session data
  gets overwrite due to a lack of session file locking.
  -eric
 


 -eric:

 You didn't provide the reason why, but you did provide a solution.

 Changing the variable names to be different than the session names fixed
 the problem.

 Now, if any php guru would care to tell me why, I would really like to
 know.

 Thanks eric.

 Cheers,

 tedd


 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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




[PHP] $_SESSION problem [NOW SOLVED]

2008-04-11 Thread tedd

At 11:33 AM -0400 4/11/08, Daniel Brown wrote:

On Fri, Apr 11, 2008 at 10:29 AM, Ford, Mike [EMAIL PROTECTED] wrote:


  Sounds like a register_globals=On issue


It does to me, as well.  I know, Tedd, that on the php1.net site
that you mentioned to me off-list, I'm about 99% positive that it's
the reason.  Shared hosts generally keep register_globals on and leave
it up to the individual customer to turn it off.  On that particular
server, though, since it's mostly developers, I may just send out an
email to get feedback and turn it off at the main, and then allow
ya'all to override it on your individual sites.

The thing that makes me wonder (and I haven't checked myself to
verify) is why two sites, on the same server, having the same


Hey!

I found it and you were right.

On my webbytedd.com site, I had a htaccess file that read:

AddDefaultCharset utf-8

php_value register_globals 0
php_value magic_quotes_gpc 0
php_value magic_quotes_sybase 0
php_value magic_quotes_runtime 0

And I didn't have that htaccess file on my sperling.com site. 
However, what fooled me was in both scripts I had:


ini_set( 'register_globals', '0' );

So, I thought that was the same, but apparently it's not. Maybe 
because my server had safe_mode ON it won't allow it -- I don't know. 
Another question for another time.


Thanks a bunch guys!

Cheers,

tedd

PS: I did try the session_write_close and several other suggestions, 
but none worked.


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

[PHP] $_SESSION problem

2008-04-10 Thread tedd

Hi gang:

I'm stumped and in need of some expert explanation.

I have prepared two demos (showing code) for your enjoyment:

[1] http://www.webbytedd.com/x/index.php
[2] http://sperling.com/x/index.php

Both of these demos have the exact same code; and are on the same 
server; with exactly the same php-info -- so, why do they behave 
differently re sessions?


Note that [1] will retain the session values throughout the entire 
session, while [2] does not and loses session values.


Why?

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] $_SESSION problem

2008-04-10 Thread Nathan Nobbe
On Thu, Apr 10, 2008 at 4:29 PM, tedd [EMAIL PROTECTED] wrote:

 Hi gang:

 I'm stumped and in need of some expert explanation.

 I have prepared two demos (showing code) for your enjoyment:

 [1] http://www.webbytedd.com/x/index.php
 [2] http://sperling.com/x/index.php

 Both of these demos have the exact same code; and are on the same server;
 with exactly the same php-info -- so, why do they behave differently re
 sessions?

 Note that [1] will retain the session values throughout the entire
 session, while [2] does not and loses session values.


as a sanity check have you dumped out the contents of the session after
writing to it on [2] ?
eg.

?php
// 

 $_SESSION['q6'] = ( isset($_SESSION['q6']) ? $_SESSION['q6'] : 0);
$_SESSION['q7'] = ( isset($_SESSION['q7']) ? $_SESSION['q7'] : 0);
$_SESSION['q8'] = ( isset($_SESSION['q8']) ? $_SESSION['q8'] : 0);
$_SESSION['q9'] = ( isset($_SESSION['q9']) ? $_SESSION['q9'] : 0);
var_dump($_SESSION);
?

also, doubtful or id assume youd mention it; but do you have .htaccess on
either of the sites?  you might just dump out the session component of the
php config on each site to ensure theyre the same.

-nathan


Re: [PHP] $_SESSION problem

2008-04-10 Thread Nathan Nobbe
On Thu, Apr 10, 2008 at 5:05 PM, Nathan Nobbe [EMAIL PROTECTED]
wrote:

 On Thu, Apr 10, 2008 at 4:29 PM, tedd [EMAIL PROTECTED] wrote:
   you might just dump out the session component of the php config on each
 site to ensure theyre the same.


on that last note, this could be useful,

?php
die(var_dump(ini_get_all('session')));
?

-nathan


Re: [PHP] $_SESSION problem

2008-04-10 Thread Eric Wood

tedd wrote:


[1] http://www.webbytedd.com/x/index.php
[2] http://sperling.com/x/index.php

Both of these demos have the exact same code; and are on the same 
server; with exactly the same php-info -- so, why do they behave 
differently re sessions?


Strange.  I've run into issues whenever I use variable names which are 
the same as session variables.  It's as if they step on each others 
toes.  I try to use uniq var names.  I've also recently run into 
customized 401 pages (which you may not see happen, check the logs) 
start up and the session data gets overwrite due to a lack of session 
file locking. 


-eric

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



Re: [PHP] $_SESSION problem

2008-04-10 Thread paragasu
it looks fine to me. but i want to share one bad experience with sessions.
the code i wrote work just fine on my testing server (please note, the
phpinfo is same with
my production server).

after days of figuring out why the session do not work. finally, i found the
solutions.
the solutions is to add a

@session_write_close() on the end of the execution code. on my case it
happen
every time i forward the page. so adding the @session_write_close before the
header('location: ') fix the problem.

this might be a possible explanation..


Re: [PHP] $_SESSION problem

2008-04-10 Thread mike
I believe you can accomplish the same thing by just putting this in:

register_shutdown_function('session_write_close');



On 4/10/08, paragasu [EMAIL PROTECTED] wrote:
 it looks fine to me. but i want to share one bad experience with sessions.
 the code i wrote work just fine on my testing server (please note, the
 phpinfo is same with
 my production server).

 after days of figuring out why the session do not work. finally, i found the
 solutions.
 the solutions is to add a

 @session_write_close() on the end of the execution code. on my case it
 happen
 every time i forward the page. so adding the @session_write_close before the
 header('location: ') fix the problem.

 this might be a possible explanation..


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