redarrow Posted May 28, 2007 Share Posted May 28, 2007 // would this in thory make all the varables in the array as a set session. example would the var of name password and message all be set varables to use bye using the below code. <?php session_start(); $x=array('$name','$password','$message'); foreach($x as $var){ $var=session($var); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53292-solved-set-all-sessions-at-once-via-a-array/ Share on other sites More sharing options...
wildteen88 Posted May 28, 2007 Share Posted May 28, 2007 session() doesn't even exist. To create a session variable you'll use $_SESSION. - Man you been around for awhile you should know by now. Oh and remove the single quotes around the variables in the array. With that correction your code should work. You could even do it like this, no need for the foreach: session_start(); $arr = array('name' => $name, 'pass' => $password, 'msg' => $message); $_SESSION = $arr; Quote Link to comment https://forums.phpfreaks.com/topic/53292-solved-set-all-sessions-at-once-via-a-array/#findComment-263350 Share on other sites More sharing options...
redarrow Posted May 28, 2007 Author Share Posted May 28, 2007 ok cheers wildteen was only a quick thing but thanks. sorry for the typed mistakes Quote Link to comment https://forums.phpfreaks.com/topic/53292-solved-set-all-sessions-at-once-via-a-array/#findComment-263352 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.