Jump to content

can insert string into $_SESSION, but not INT


niche

Recommended Posts

this works: array(1) { ["snpos"]=> string(1) "5" }$pos = 5;$pos = strval($pos);$_SESSION['snpos'] = $pos;echo var_dump($_SESSION) . '</br>'; but this doesn't: array(1) { ["snpos"]=> int(5) } $pos = 5;$_SESSION['snpos'] = $pos;echo var_dump($_SESSION) . '</br>'; Why can't I define a session key with a INT value?

Link to comment
Share on other sites

did you check the manual page?http://www.php.net/manual/en/session.examples.basic.phpit's right there at the top:

The keys in the $_SESSION associative array are subject to the same limitations as regular variable names in PHP, i.e. they cannot start with a number and must start with a letter or underscore.
Link to comment
Share on other sites

Hmm, I just read your question

Why can't I define a session key with a INT value?
and replied to that.So upon reflection, what about this:
array(1) { ["snpos"]=> int(5) }

is a problem?

Link to comment
Share on other sites

I got up too early this morning (that's my story and I'm sticking to it). thescientist, thanks for your time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...