Page 3 of 3

Posted: Mon May 28, 2007 9:39 am
by superdezign
franknu wrote:the problem is that i should also display the password and it is only displaying the user
That's because the only thing that you are saving is the user.
franknu wrote:

Code: Select all

$_SESSION = array('User_Name'=>$_POST['User_Name']);
If you want both, save both into the array. I, personally, wouldn't recommend saving the password, as you should only need to check once, but it's up to you.



And it IS carrying the user name to the next page. It's in the $_SESSION array.

Posted: Mon May 28, 2007 10:14 am
by franknu
Ok On Page1

with <pre>_SESSION:<?php print_r($_SESSION); ?></pre>

i am displaying this

SESSION:Array
(
[User_Name] => franklin
[Password] => franklin01
)


and here is my code

Code: Select all

<?
if ( isset($_POST['User_Name']) && isset ( $_POST['Password']) ) { 
        session_start(); 
        session_regenerate_id(); 
  $_SESSION = array('User_Name'=>$_POST['User_Name'] , 
                                 'Password'=>$_POST['Password']); 
           
}
?>
however on page2


i am displaying

SESSION:Array
(
[User_Name] =>
[Password] =>
)

with <pre>_SESSION:<?php print_r($_SESSION); ?></pre>

and this is the code for page2

Code: Select all

<?php 
session_start(); 
if (isset($_SESSION['User_Name']) && isset($_SESSION['Password']))  { 
 session_regenerate_id(); 
        $_SESSION = array('User_Name'=>$_POST['User_Name'] , 
                                 'Password'=>$_POST['Password']);        
} 
?>



<html>

Posted: Mon May 28, 2007 10:29 am
by superdezign
... Odd. Where are you testing from?

Posted: Mon May 28, 2007 10:32 am
by franknu
i dont get ur answer but when i take the Session to the next page it is not displaying the values

Posted: Mon May 28, 2007 10:40 am
by superdezign
Lol, I understood you the first time.

Are you testing locally or remotely?

Posted: Mon May 28, 2007 11:04 am
by franknu
Remote, everything is on the server already

Posted: Mon May 28, 2007 11:27 am
by volka
franknu wrote:and this is the code for page2

Code: Select all

<?php 
session_start(); 
if (isset($_SESSION['User_Name']) && isset($_SESSION['Password']))  { 
 session_regenerate_id(); 
        $_SESSION = array('User_Name'=>$_POST['User_Name'] , 
                                 'Password'=>$_POST['Password']);        
} 
?>
Why do you assign the array again on page 2? Are User_Name and Password POSTed again?
No they are not. Script #1 sets the session data, script #2 uses them.

Posted: Mon May 28, 2007 12:45 pm
by superdezign
volka wrote:
franknu wrote:and this is the code for page2

Code: Select all

<?php 
session_start(); 
if (isset($_SESSION['User_Name']) && isset($_SESSION['Password']))  { 
 session_regenerate_id(); 
        $_SESSION = array('User_Name'=>$_POST['User_Name'] , 
                                 'Password'=>$_POST['Password']);        
} 
?>
Why do you assign the array again on page 2? Are User_Name and Password POSTed again?
No they are not. Script #1 sets the session data, script #2 uses them.
Wow.. It's as though I stopped reading at session_regenerate_id(); (.. which I did :-p).