Re: [PHP] Re: More questions about SESSION use
On Mon, Feb 2, 2009 at 4:18 PM, Chris dmag...@gmail.com wrote: Edmund Hertle wrote: 2009/2/1 Terion Miller webdev.ter...@gmail.com This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Those two lines after header() will not be executed. Yes they will because there is no 'exit'. Header is just a function call, if you want to stop processing you have to do it yourself. -- Postgresql php tutorials http://www.designmagick.com/ Is it better to use the session_register() could that be my issue ,although my sessions are passing from page to page so they are registered? right... is this part of that loose format that php coders just love and I hate..because it to me makes learning it hard... t.
Re: [PHP] Re: More questions about SESSION use
On Thu, Feb 5, 2009 at 9:16 AM, Terion Miller webdev.ter...@gmail.comwrote: On Mon, Feb 2, 2009 at 4:18 PM, Chris dmag...@gmail.com wrote: Edmund Hertle wrote: 2009/2/1 Terion Miller webdev.ter...@gmail.com This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Those two lines after header() will not be executed. Yes they will because there is no 'exit'. Header is just a function call, if you want to stop processing you have to do it yourself. -- Postgresql php tutorials http://www.designmagick.com/ Is it better to use the session_register() could that be my issue ,although my sessions are passing from page to page so they are registered? right... is this part of that loose format that php coders just love and I hate..because it to me makes learning it hard... t. FYI session_register is deprecated in PHP 5.3.0 and completely going away in PHP 6.0. Please don't use it. Thanks, V
Re: [PHP] Re: More questions about SESSION use
On Thu, 2009-02-05 at 11:16 -0600, Terion Miller wrote: On Mon, Feb 2, 2009 at 4:18 PM, Chris dmag...@gmail.com wrote: Edmund Hertle wrote: 2009/2/1 Terion Miller webdev.ter...@gmail.com This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Those two lines after header() will not be executed. Yes they will because there is no 'exit'. Header is just a function call, if you want to stop processing you have to do it yourself. -- Postgresql php tutorials http://www.designmagick.com/ Is it better to use the session_register() could that be my issue ,although my sessions are passing from page to page so they are registered? right... is this part of that loose format that php coders just love and I hate..because it to me makes learning it hard... t. Just use a session_start() before any output to the server, and the sessions array will be available to your code. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: More questions about SESSION use
Just use a session_start() before any output to the server, and the sessions array will be available to your code. Ash www.ashleysheridan.co.uk Ah ha...and now I know why my O'reilly book Web Database Applications with PHP was so inexpensive... :) it's outdated...oops...
Re: [PHP] Re: More questions about SESSION use
Show the code where your session vars are written and I would prefer using isset() instead of empty() if you want to check if this var is set or not. -eddy Hi All, here is the index page where users login and the sessions are set: ?php //start session session_start(); //db connection include include(inc/dbconn_open.php) ; //errors on error_reporting(E_ALL); ini_set('display_errors', '1'); if (!empty($_POST['UserName']) !empty($_POST['Password'])) { $UserName = $_POST['UserName']; $Password = $_POST['Password']; } $msg = ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user'] = $UserName; $_SESSION['AdminID'] = $row-AdminID; header ('Location: Main.php'); exit; } else { $msg = Sorry You Entered An Invalid LoginbrPlease Try AgainbrClick to Contact a href='mailto:b...@blahblah.com'bblah blah/b/a If You Need Help; } } //include (VariableReveal2.php); ?
Re: [PHP] Re: More questions about SESSION use
Edmund Hertle wrote: 2009/2/1 Terion Miller webdev.ter...@gmail.com This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Those two lines after header() will not be executed. Yes they will because there is no 'exit'. Header is just a function call, if you want to stop processing you have to do it yourself. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: More questions about SESSION use
2009/2/1 Terion Miller webdev.ter...@gmail.com This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Those two lines after header() will not be executed. Hi David, yes I have session_start(); on everypage very 1st line. terio Show the code where your session vars are written and I would prefer using isset() instead of empty() if you want to check if this var is set or not. -eddy
Re: [PHP] Re: More questions about SESSION use
This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Is the above part not needed since the Session is already active? Should I be not using the header part (honestly I havent read up on that chapter yet) Are you using session_start()? Cheers -- David Robley Hi David, yes I have session_start(); on everypage very 1st line. terio
[PHP] Re: More questions about SESSION use
Terion Miller wrote: So now I have SESSIONs set: user, AdminID, AdminLogin but I'm trying to use them without showing them in links...currently the pages only load if I make the links like this: a href=Welcome.php?AdminID=?php echo $_SESSION['AdminID']; ? target=mainFrameHome/a I thought the whole purpose of having/using Sessions is to not have to pass variables in url's, but if I remove the session in the link above when I click to it, It logs me out, even though it IS holding the SESSION (which I checked by revealing my variables) so I guess I am confused about this bit of code, I think its saying if the SESSION is there great if not logout... but even when I expose the variables and see that the session is passing from page to page it keeps sending me to the logout page: This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Is the above part not needed since the Session is already active? Should I be not using the header part (honestly I havent read up on that chapter yet) Are you using session_start()? Cheers -- David Robley The Hubbell works fine; all that stuff IS blurry! Today is Boomtime, the 32nd day of Chaos in the YOLD 3175. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php