By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,408 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,408 IT Pros & Developers. It's quick & easy.

WTF!? - $_SESSION passes vars BUT NOT ARRAYS!?!?!?!?!?!

P: n/a
h
I am at my wits end; I can not see A SINGLE THING I'm doing wrong. I've
read every fricking session related doc. I've searched every fricking
group.
NO ONE seems to have had the problem I'm having - and it doesn't make
ANY sense.

I'm running php 4.3.3 on a local server; and 4.3.10 on my isp's web
server.
I've tested this on both with the same results.

all I fricking want to do is pass an array from 1 script to the next -
sure sounds simple enough - right?

here's my code:
__________________________________________________ ________________________
TEST1.PHP:
session_start();

$myarr=array(); $hw='hello world! (of course!)';
$_SESSION['hw']=$hw;
$_SESSION['1']='purple people eater'; $_SESSION['house']='1 eyed 1
house pppe';
$myarr['2']='purple people eater'; $myarr['home']='1 eyed 1 house
pppe';

$_SESSION['myarr']=$myarr;
$_SESSION['smyarr']=serialize($myarr); // I should NOT have to do this

print_r($_SESSION); // YES - all the var's actually have stuff in 'em
print '<BR><BR>myarr:<BR> '; print_r($myarr); print '<BR><BR>';
print 'smyarr:<BR> '; print_r($_SESSION['smyarr']); print '<BR><BR>';
print '<BR><A href="test2.php">continue here</a>';
__________________________________________________ ________________________
TEST2.PHP:
session_start();

echo '<BR><BR>_REQUEST:<BR> '; // should be no point, but I'm trying
anything
print_r($_REQUEST); // of course, my SID is in here - no surprise.
echo '<BR><BR>_SESSION:<BR> ';
print_r($_SESSION);
// this SHOULD have my arrays! but it doesn't even have
// my serialized string !!!!!!!!!!!!! HOW CAN THAT BE!?!?!?!?!?
// if $hw passes thru - which it does - how can smyarr NOT pass?!?!
__________________________________________________ ________________________
Here's the results from test2.php:
_SESSION:
Array ( [hw] => hello world! (of course!) )
// where the blank is all my other stuff!?!
__________________________________________________ ________________________

would be most appreciative, and eternally grateful if anyone could tell
me what my problem is!! (my programming problem that is :-)

tia - Bob
PS: my REAL email has the 3 letters reversed - ie: abc=cba

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
h@s@n@starnetwx.net wrote:
I am at my wits end; I can not see A SINGLE THING I'm doing wrong. I've read every fricking session related doc. I've searched every fricking
group.
NO ONE seems to have had the problem I'm having - and it doesn't make
ANY sense.

I'm running php 4.3.3 on a local server; and 4.3.10 on my isp's web
server.
I've tested this on both with the same results.

all I fricking want to do is pass an array from 1 script to the next - sure sounds simple enough - right?

here's my code:

<... SNIP CODE ...>

You cannot have numeric keys into $_SESSION, $_GET, $_POST, etc.

--
Oli

Jul 17 '05 #2

P: n/a
h
hi Oli -

True enough - but none of my keys are numeric - they're strings that
happen to use a number - right?

$_SESSION['1']='purple people eater';
$myarr['2']='purple people eater';
<<

tia - Bob

Jul 17 '05 #3

P: n/a
h
well - SOB !

I THOUGHT those numbers would be treated as strings, because I quoted
them - apparently not!

removed them and things are right in the world again!!

1M TX, Oli; although still not sure why a number treated as a string
would cause problems...

Bob

Jul 17 '05 #4

P: n/a
h@s@n@starnetwx.net wrote:
well - SOB !

I THOUGHT those numbers would be treated as strings, because I quoted
them - apparently not!

removed them and things are right in the world again!!

1M TX, Oli; although still not sure why a number treated as a string
would cause problems...


I think it must be a throwback to allow register_globals to work.

When register_globals is enabled, $_SESSION['monkey'] becomes $monkey.
Therefore a variable such as $_SESSION[1] (or $_SESSION['1']) would
become $1, which is obviously not a valid variable name.

The only way to resolve this is not to allow $_SESSION[1] in the first
place.

--
Oli

Jul 17 '05 #5

P: n/a
h

Oli Filth wrote:
h@s@n@starnetwx.net wrote:
I THOUGHT those numbers would be treated as strings, because I quoted them - apparently not!

removed them and things are right in the world again!!

1M TX, Oli; although still not sure why a number treated as a string would cause problems...

I think it must be a throwback to allow register_globals to work.

When register_globals is enabled, $_SESSION['monkey'] becomes

$monkey. Therefore a variable such as $_SESSION[1] (or $_SESSION['1']) would
become $1, which is obviously not a valid variable name.

The only way to resolve this is not to allow $_SESSION[1] in the first place.

--
Oli


That, at least, makes some sense!

TX again, Oli!
-Bob

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.