Branden Wagner Posted August 5, 2006 Share Posted August 5, 2006 .. i read somewhere.. awhile ago, that you should not user multidimensional arrays within a session var...can anyone elaborate or tell my the downsides of itbecause im using...[code]$_SESSION['authorized_user'] = array();$_SESSION['authorized_user']['username']= $_SERVER['PHP_AUTH_USER'];$_SESSION['authorized_user']['password']= $_SERVER['PHP_AUTH_PW'];$_SESSION['authorized_user']['info']['email'] = // queried from db#.... i think you get the point[/code]basically i store all the users common info(used frequently) into the session array..i was just wondering if there was a better way to do...also didnt there used to be a session tutorial on this site somewhere?? i cant seem to find it.i found one http://www.phpfreaks.com/tutorials/41/0.phpbut that doesnt seem to work.. Quote Link to comment https://forums.phpfreaks.com/topic/16668-multidimensional-session-array/ Share on other sites More sharing options...
zq29 Posted August 6, 2006 Share Posted August 6, 2006 I've never heard that you should not use multidimensional session arrays, there are no downsides that are instantly obvious... I've used them several times with no problems. Quote Link to comment https://forums.phpfreaks.com/topic/16668-multidimensional-session-array/#findComment-70112 Share on other sites More sharing options...
ignace Posted August 6, 2006 Share Posted August 6, 2006 It won't harm i guess, however i won't go as deep as you do $_SESSION['user_information']['info']['email'].. rather i would stick to something like this $_SESSION['user_information']['user_email'] however i only use sessions to store information, but i never get the information directly from it, only when a parent file is being executed the complete session is being loaded into my session object, so whenever i need something from my session i get it from my object in the order of: $Context->Session->GetVariable('user_email'); and because of my context object also controls my database, can i even check if the retrieved data is correct, if required. Quote Link to comment https://forums.phpfreaks.com/topic/16668-multidimensional-session-array/#findComment-70118 Share on other sites More sharing options...
king arthur Posted August 6, 2006 Share Posted August 6, 2006 [quote author=Branden Wagner link=topic=103123.msg410424#msg410424 date=1154818242].. i read somewhere.. awhile ago, that you should not user multidimensional arrays within a session var...can anyone elaborate or tell my the downsides of itbecause im using...[code]$_SESSION['authorized_user'] = array();$_SESSION['authorized_user']['username']= $_SERVER['PHP_AUTH_USER'];$_SESSION['authorized_user']['password']= $_SERVER['PHP_AUTH_PW'];$_SESSION['authorized_user']['info']['email'] = // queried from db#.... i think you get the point[/code]basically i store all the users common info(used frequently) into the session array..i was just wondering if there was a better way to do...also didnt there used to be a session tutorial on this site somewhere?? i cant seem to find it.i found one http://www.phpfreaks.com/tutorials/41/0.phpbut that doesnt seem to work..[/quote]Why are you using a key 'authorized_user' though? Does your array have other keys for other types of user too? Or is it just to separate those variables from other variables with similar names in the session array? Quote Link to comment https://forums.phpfreaks.com/topic/16668-multidimensional-session-array/#findComment-70120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.