Jump to content

bwspot

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by bwspot

  1. thx , above with http://www.phpriot.com/articles/intro-php-sessions/7 helped me to understand it and fixed my issue
  2. i do have session_start() at the begining of the script and I commented out the session_register. The part i dont understand is how to store the data in the session array ? My php page contains: session_start() $_SESSION['phonenumber'] = mysql_result($result,0,'phonenumber'); $_SESSION['username'] = mysql_result($result,0,'username'); $_SESSION['userlevel'] = mysql_result($result,0,'userlevel'); then i am not sure if this is what i need to store above in the array? $session = array(); if yes how do i read it later? thx and sorry for stupid questions but i am new to all this stuff and dont programm that often.
  3. The phone number is pulled from the data based based on the username that authenticates. So it is different for every user. After the user is redirected the $phonenumber variable is empty. the referenced paga says: "Caution This registers a global variable. If you want to register a session variable from within a function, you need to make sure to make it global using the global keyword or the $GLOBALS[] array, or use the special session arrays as noted below. " I tried to add: global $phonenumber but the varriable was still empty after redirection
  4. I have auth page that auth user against php and later registers data from mysql querry into the session varriables like this: //register sesssion authenticated else {$_SESSION['authenticated']=true; //register other values $sessionid=session_id(); $_SESSION['phonenumber'] = mysql_result($result,0,'phonenumber'); $_SESSION['username'] = mysql_result($result,0,'username'); $_SESSION['userlevel'] = mysql_result($result,0,'userlevel'); //session_register("userlevel"); //session_register("email"); //session_register("sitename"); //session_register("ipaddr"); //session_start(); - old and replaced by below line $session = array(); after all is done the user is redirected back to: header("Location: main.php?".Session_Name()."=".Session_ID()); and in main.php varriables are called like: dbConnect("corporate"); $mysql = "select * from users WHERE phonenumber = $phonenumber"; $rs = mysql_query($mysql); $row = mysql_fetch_array($rs); echo "phone is"; echo $phonenumber; echo "global phone is "; echo $GLOBALS['phonenumber']; Problem is that after register_global was removed from php above $phonenumber varriable is empty. I have seen this link: http://uk3.php.net/manual/en/function.session-register.php but i have hard time understanding how to fix above. Every page has a session_start() at the beggining. Can anyone help how to fix my script with the least changes? I am using php from time to time so forgive me my lack of expertise. thx
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.