p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > PHP/MySQL > Pro PHP
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 22nd, 2008, 07:58 PM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 5th, 2008, 08:35 AM
Registered User
 
Join Date: Nov 2007
Location: , , India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to v08i
Default

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old December 21st, 2008, 01:57 AM
Authorized User
Points: 43, Level: 1
Points: 43, Level: 1 Points: 43, Level: 1 Points: 43, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: mukalla, , Yemen.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<?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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old April 4th, 2009, 12:16 AM
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Burla, Orissa, India.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to paagle
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
session variable lost after redirec in classic ASP beetle_jaipur Classic ASP Professional 8 November 21st, 2008 02:18 AM
Session Value Getting Lost sid81 .NET Framework 2.0 3 October 13th, 2007 11:15 AM
$_POST[variable] in quotes? PHP5 gs99 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 March 2nd, 2007 04:13 PM
Partial Session Lost kiasemoto Classic ASP Professional 0 January 25th, 2007 03:54 AM
Session variables being lost! LenexaKS ASP.NET 1.0 and 1.1 Basics 12 November 13th, 2006 01:46 PM



All times are GMT -4. The time now is 10:59 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc