Jump to content

session


astralaaron

Recommended Posts

Hi, when users log into my program something similar to the code below happens.. some info is stored in sessions like username etc..One of the sessions (b in the example) I want to be an array, so I can keep adding to it etc... it works fine.the problem I am having is after I added that array to the session, when I try to directly echo($_SESSION['a']); nothing happens....but if I do this: echo('test: '.$_SESSION['a']); then it will output 'test: 10'does anyone understand what is happening?

<?php session_start(); $_SESSION['a'] = "";$_SESSION['b'] = array();// somewhere down the line:$_SESSION['b'][] = "example...asdf asdf asdf ";$_SESSION['b'][] = "example2...asdf asdf asdf ";// further down the line:$_SESSION['a'] = 10;?>

Link to comment
Share on other sites

That makes no sense at all, unless it's a parsing error or a cache problem. "nothing happens...." is not very clear. Does the rest of the script perform, or are you getting nothing but white screen? If error reporting is off, it is sometimes helpful to put a short echo statement at the top of the script just to make sure the thing parses.I'm assuming the echo statement comes after the $_SESSION['a'] = 10; statement?

Link to comment
Share on other sites

That makes no sense at all, unless it's a parsing error or a cache problem. "nothing happens...." is not very clear. Does the rest of the script perform, or are you getting nothing but white screen? If error reporting is off, it is sometimes helpful to put a short echo statement at the top of the script just to make sure the thing parses.I'm assuming the echo statement comes after the $_SESSION['a'] = 10; statement?
it's really weird... no errors come up, just white.the echo is a test because all the sudden things stopped working once I added that array to the session.echo($_SESSION['a']); = white screenecho('test: '.$_SESSION['a']) = test: 10EDIT: also when I print_r($_SESSION) everything looks correct.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...