p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   PHP Databases (http://p2p.wrox.com/forumdisplay.php?f=97)
-   -   Problem passing through sessions (http://p2p.wrox.com/showthread.php?t=28603)

dmlocke April 26th, 2005 05:07 PM

Problem passing through sessions
 
Hi,

I am working on chapter 2 of beginning php,mysql and apache - moviesite.php and movie1.php. I am now working on Passing variables through sessions. I have cut and past the code (which I downloaded from the wrox site) for both php files (therefore if the code is coming from the source, it surely must be ok).

Every time I click the hyperlink: "click here to see information...." on the movie1.php, it should return:

Welcome to our site Joe 12345
My favourite movie is Life of Brian
My movie rating for this movie is : 5

However (even when I use the code from the book) No session information is passed at all, and all I get is:


My favorite movie is Life of Brian
My movie rating for this movie is: 5

I have checked the registered globals are off (they are) and made sure the php.ini file "session_save_path" is pointing to the C:/temp (which it is).

Does anybody no whats wrong or what I am doing wrong? I basically can't progress through the book until I resolve the problem as the next section uses sessions and cookies, and It won't work if the sessions don't work.

Help!!!!!

Kind regards
David

richard.york April 26th, 2005 05:19 PM

Quote:

quote:
This is really pissing me off now!
Not the best way to solicit help from the community.

The book does have a forum:
http://p2p.wrox.com/book-asp-net-website-programming-problem-design-solution-23/0 (PHP 4 Book)
http://p2p.wrox.com/forum.asp?FORUM_ID=157 (PHP 5 Book)

Troubleshooting Sessions:
Did you restart Apache after setting the session.save_path directive?

Can you verify that session files are being created at C:\temp?

What about the session id, are you passing the session id via a URL or via cookies?

Are cookies enabled in your browser?

Can you verify that a session cookie is being created by your browser (find the raw cookie file for your domain)?

Does the cookie file have the session id in it?

Do you have a firewall enabled (sometimes a firewall can cause conflicts with the session cookie)?

Do you have error_reporting activated (error_reporting = E_ALL in php.ini)?

Are errors being logged (log_errors = off in php.ini)?

Are errors being displayed (display_errors = on in php.ini)?

As you can see lots of things can be misconfigured and cause you to miss out on error information, or cause your sessions to fail.

Finally, since not everyone has the book, post relevant snips of code, so we can see what you're working with.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design

dmlocke April 26th, 2005 05:41 PM

Here is the code I have used....

Movie1.php:

<?php
session_start();
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my Favorite Movie!</TITLE>
</HEAD>
<BODY>
<?php
     $myfavmovie=urlencode("Life of Brian");
     echo "<a href='http://localhost/moviesite.php?favmovie=$myfavmovie'>";
     echo "Click here to see information about my favorite movie!";
     echo "</a>";
?>
</BODY>
</HTML>
<?php
session_start();
//check to see if user has logged in with a valid password
     if ($_SESSION['authuser']!=1) {
     echo "Sorry, but you don't have permission to view this page, you loser!";
     exit();
     }
?>
<HTML>
<HEAD>
<TITLE>My Movie Site - <?php echo $_REQUEST['favmovie'] ?></TITLE>
</HEAD>
<BODY>
<?php
     echo "Welcome to our site, ";
     echo $_SESSION['username'];
     echo "! <br>";
     echo "My favorite movie is ";
     echo $_REQUEST['favmovie'];
     echo "<br>";
     $movierate=5;
     echo "My movie rating for this movie is: ";
     echo $movierate;

?>
</BODY>
</HTML>

Hope this helps.

David



anshul June 15th, 2005 03:17 AM

Where are you passing SID?
Or do you've set session.use_trans_sid = 1 ?


nigieboy June 26th, 2006 08:08 PM

I have the same problem. I have spent 3 days looking at forums and have yet to find anyone with the solution to this problem.

The exact problem is that variables are not being passed form one page to another, either by post or sessions on my localhost. A large number of requests have been asked on different forums but no real answers have been given, hoping to get one here.

everyone just gives standard answers like use post and gives and examples , put session ast start of page (i know how to pass variables, I have done it hundreds of timesit works but not on my localhost)

I know how to do this it works on isp host
as do session but not no my local server. I have a number of site that work perfectly with sessions and passing from variables on isps but the same will not work on my localhost.

I have configed session to be on
register globals = off etc

tried adjusting buffer output.

I am using easyphp on a windows xp machine with apache server. I have upgraded php to 5 as I thought that might be the problem but still no fix.

Its as if the varibles are just not being sent. Because I can echo them on one page but when next page is loaded they do not exsist.

I really need help as I cannot develop locally with this continious problem..

cheers




All times are GMT -4. The time now is 12:40 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.