FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Transfer session variables with netBeans

 
Post new topic   Reply to topic    NetBeans Forums -> PHP Users
View previous topic :: View next topic  
Author Message
bidahly



Joined: 18 Mar 2009
Posts: 2

PostPosted: Thu Mar 19, 2009 12:20 am    Post subject: Transfer session variables with netBeans Reply with quote

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
View user's profile Send private message
Eugene Morgan
Posted via mailing list.





PostPosted: Thu Mar 19, 2009 1:28 pm    Post subject: Transfer session variables with netBeans Reply with quote

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

PostPosted: Thu Mar 19, 2009 2:03 pm    Post subject: Reply with quote

Thanks for your reply;
but It didn't work even with "username"...



SESSION.zip
 Description:
I attached the 2 pages just in case

Download
 Filename:  SESSION.zip
 Filesize:  2.37 KB
 Downloaded:  49 Time(s)

Back to top
View user's profile Send private message
Eugene Morgan
Posted via mailing list.





PostPosted: Thu Mar 19, 2009 6:42 pm    Post subject: Transfer session variables with netBeans Reply with quote

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:
Quote:
Thanks for your reply;

but It didn't work even with "username"...




Attachments:
http://forums.netbeans.org//files/session_129.zip




([email]address-removed[/email])
([email]address-removed[/email])



Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> PHP Users All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB