please help me in session in php

Reply

Join Date: May 2008
Posts: 28
Reputation: almualim is an unknown quantity at this point 
Solved Threads: 0
almualim almualim is offline Offline
Light Poster

please help me in session in php

 
0
  #1
May 6th, 2008
i want to send variable from one page to other in php and iam using session, but the variable doesn't appear in other page. iam using this code :

page 1:
<?php
session_register('number');
$number =10;
header("Location: page2.php");
?>

page 2:
<?php
echo"number= ".$number;
?>
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 883
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 144
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: please help me in session in php

 
0
  #2
May 6th, 2008
use:

if (! session_id()) session_start();

at the top of each page.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 28
Reputation: almualim is an unknown quantity at this point 
Solved Threads: 0
almualim almualim is offline Offline
Light Poster

Re: please help me in session in php

 
0
  #3
May 6th, 2008
thanks pritaeas:
but the problem still found.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: please help me in session in php

 
0
  #4
May 6th, 2008
  1. <?php
  2. //page1.php
  3. session_start();
  4. $_SESSION['number'] = 10;
  5. header("Location: page2.php");
  6. ?>
and
  1. <?php
  2. //page2.php
  3. session_start();
  4. echo"number= ".$_SESSION['number'];
  5. ?>

If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.
Source : http://nl2.php.net/manual/en/functio...n-register.php
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 28
Reputation: almualim is an unknown quantity at this point 
Solved Threads: 0
almualim almualim is offline Offline
Light Poster

Re: nav33n

 
0
  #5
May 7th, 2008
it's working very well ,thank you very much (nav33n).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 555 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC