| View previous topic :: View next topic |
| Author |
Message |
bidahly
Joined: 18 Mar 2009 Posts: 2
|
Posted: Thu Mar 19, 2009 12:20 am Post subject: Transfer session variables with netBeans |
|
|
I'm having a problem with transferring data stored in session to another
page.
for eg :
//on page1.php:
<?php
...
session_start();
$user = $_POST["username"];
$_SESSION["username"] = $user;
header('Location: page2.php');
?>
//and on page2.page:
<?php
session_start();
if (array_key_exists("user", $_SESSION)) {
echo "Hello " . $_SESSION["user"];
} else {
header('Location: index.php');
exit;
}
?>
The problem is that $_SESSION doesn't display any value on page2.php
while I have arleady stored it in.
How can I fix this?
Thank you
|
|
| Back to top |
|
 |
Eugene Morgan Posted via mailing list.
|
Posted: Thu Mar 19, 2009 1:28 pm Post subject: Transfer session variables with netBeans |
|
|
It looks like on page 1 you are setting a value for $_SESSION['username'] but on page 2 you are trying to call the value for $_SESSION['user']. Just change "user" to "username" on page 2.
On Wed, Mar 18, 2009 at 7:20 PM, bidahly <address-removed ([email]address-removed[/email])> wrote:
| Quote: | I'm having a problem with transferring data stored in session to another
page.
for eg :
//on
|
|
| Back to top |
|
 |
bidahly
Joined: 18 Mar 2009 Posts: 2
|
Posted: Thu Mar 19, 2009 2:03 pm Post subject: |
|
|
Thanks for your reply;
but It didn't work even with "username"...
| Description: |
| I attached the 2 pages just in case |
|
 Download |
| Filename: |
SESSION.zip |
| Filesize: |
2.37 KB |
| Downloaded: |
49 Time(s) |
|
|
| Back to top |
|
 |
Eugene Morgan Posted via mailing list.
|
Posted: Thu Mar 19, 2009 6:42 pm Post subject: Transfer session variables with netBeans |
|
|
Hmm, not sure. You might try posting the question in a PHP forum like sitepoint.
On Thu, Mar 19, 2009 at 9:03 AM, bidahly <address-removed ([email]address-removed[/email])> wrote:
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|
|
|