|
|
 |
| Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Pro PHP section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

July 22nd, 2008, 07:58 PM
|
|
Registered User
|
|
Join Date: Jul 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
PHP5 session variable lost
Hi,
I am having a problem passing session variable to the next page.
I am using PHP5.2, MySQL, and Apache 2.2 on Windows XP.
I read many forums and tried different/suggested solutions without success! I would appreciate your help with this.
In page1 I am using the simple code outline below:
<?PHP
session_start();
$color="green";
$_SESSION['color'] = $color;
?>
On page2 I used:
<?php
session_start();
echo "Color = ". $_POST['color']
echo "<br>Color =" . $_SESSION['color'];
?>
However, nothing gets displayed in page2!
Several posts suggest the problem could be in the PHP.ini file.
Here's related parts of my php.ini file:
;session.save_path = "50;/W:\Apache2.2\PHP\sessions\"
session.save_path = "W:\Apache2.2\PHP\sessions\"
session.use_only_cookies = 1
;session.save_path = "/tmp"
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = "W:\Apache2.2\PHP\sessions\"
I am not a PHP expert, and I would really appreciate your help with this.
Many thanks
Totti
|

August 5th, 2008, 08:35 AM
|
|
Registered User
|
|
Join Date: Nov 2007
Location: , , India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I would like to know , how are you navigating from page 1 to page 2.
Can you just paste the whole source here
--
Vijay Joshi
http://www.vijayjoshi.org
|

December 21st, 2008, 01:57 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Location: mukalla, , Yemen.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<?PHP
session_start();
$color="green";
$_SESSION['color'] = $color;
?>
On page2 I used:
<?php
session_start();
if(isset($_SESSION['color']))
echo "<br>Color =" . $_SESSION['color'];
?>
just it's working like that
|

April 4th, 2009, 12:16 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Location: Burla, Orissa, India.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Best bet is to use variables to store SESSION within a page and re-send it to sessions at the end of a page
Eg:-
page1
$sessionc=$_SESSION['color'];
//Lines of code
/*..........
..........
..........
..............*/
//Last line of your code
$_SESSION['color']=$sessionc;
This preserves session variables that may get lost within a page
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |