Connecting Tech Pros Worldwide Forums | Help | Site Map

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

h@s@n@starnetwx.net
Guest
 
Posts: n/a
#1: Jul 17 '05
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


Oli Filth
Guest
 
Posts: n/a
#2: Jul 17 '05

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


h@s@n@starnetwx.net wrote:[color=blue]
> I am at my wits end; I can not see A SINGLE THING I'm doing wrong.[/color]
I've[color=blue]
> 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[/color]
-[color=blue]
> sure sounds simple enough - right?
>
> here's my code:[/color]
<... SNIP CODE ...>

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

--
Oli

h@s@n@starnetwx.net
Guest
 
Posts: n/a
#3: Jul 17 '05

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


hi Oli -

True enough - but none of my keys are numeric - they're strings that
happen to use a number - right?
[color=blue][color=green]
>>[/color][/color]
$_SESSION['1']='purple people eater';
$myarr['2']='purple people eater';
<<

tia - Bob

h@s@n@starnetwx.net
Guest
 
Posts: n/a
#4: Jul 17 '05

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


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

Oli Filth
Guest
 
Posts: n/a
#5: Jul 17 '05

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


h@s@n@starnetwx.net wrote:[color=blue]
> 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...
>[/color]

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

h@s@n@starnetwx.net
Guest
 
Posts: n/a
#6: Jul 17 '05

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



Oli Filth wrote:[color=blue]
> h@s@n@starnetwx.net wrote:[color=green]
> > I THOUGHT those numbers would be treated as strings, because I[/color][/color]
quoted[color=blue][color=green]
> > 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[/color][/color]
string[color=blue][color=green]
> > would cause problems...
> >[/color]
>
> I think it must be a throwback to allow register_globals to work.
>
> When register_globals is enabled, $_SESSION['monkey'] becomes[/color]
$monkey.[color=blue]
> 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[/color]
first[color=blue]
> place.
>
> --
> Oli[/color]

That, at least, makes some sense!

TX again, Oli!
-Bob

Closed Thread