p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 (http://p2p.wrox.com/forumdisplay.php?f=33)
-   -   Session Variables - help? (http://p2p.wrox.com/showthread.php?t=17417)

Annoyamouse August 25th, 2004 11:22 AM

Session Variables - help?
 
Hello all.

Are there changes required for PHP4 pages to using session variables on a server versus using session variables locally?[?]

My pages do work right now (locally) with session variables, but when I upload them to the server, it doesn't work.

I've used the session_start(), I've made certain the session variables have values in them, is there something else I'm missing? Like I said, it works locally, but not on the server. I've talked to the server administrator, and he's informed me they are active according to the PHP config file. I've also looked at the settings, and it matches mine.

Any suggestions?


richard.york August 25th, 2004 04:16 PM

Do you have a firewall running? It sounds like you are using Cookies to transmit the session id, certain software firewalls block incoming cookies.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail

Annoyamouse August 26th, 2004 04:34 PM

No, I have no cookies running anywhere in the code - I made certain no cookies are used in the pages, just session variables. Regarding a firewall, I don't have anything specific running, just the one from the Windows XP SP2 configuration (for now).

The server itself is using NT, so SP2 probably doesn't apply in this case (unless phpinfo() displays NT as the operating system even though it's XP)...


richard.york August 26th, 2004 09:04 PM

How are you transmitting the session id from server to client and from client to server? session_start() automatically generates a cookie when it is called. If you aren't embedding the session id directly in the URLs or input fields then this is how the session id is being transmitted.

If you aren't seeing any errors and you're sure that PHP is configured correctly, then it's likely a problem with the session_id.

Have a look at these threads:
http://p2p.wrox.com/topic.asp?TOPIC_ID=16857
http://p2p.wrox.com/topic.asp?TOPIC_ID=17110
http://p2p.wrox.com/topic.asp?TOPIC_ID=15613

These discuss common session problems.

HTH!


Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail

Annoyamouse August 30th, 2004 03:00 PM

Hello Richard.

I really appreciate your help on this, and I have tried your example on this link
you gave me: http://p2p.wrox.com/topic.asp?TOPIC_ID=17110

Firstpage.php:
<?php
    session_start();


    $_SESSION['foo'] = 'Hello, world!';

    echo "<a href='other_page.php?sid=".session_id()."'>Next page...</a>";
?>

Otherpage.php:
<?php
    //other_page.php
    session_start();

    echo $_SESSION['foo'];
?>

However ...

What I did was copy and pasted the code into two seperate pages. I've FTP'd them to
the server itself, and on the second page, the session variable which should have
'hello world' didn't show up.

I've already talked to the admin of the webserver and he verified the session variables
are activated and working properly. But what I get is a blank second page even with sending
the session_id along ...

Any suggestions?


richard.york August 30th, 2004 03:11 PM

Are both pages located on the same server with the same domain name?

When you view the source of the second page is it completely blank, or does the PHP code appear in the source?

If you answered yes to 1 (located on same server) and 2 (completely blank) I'd say you have a problem with how PHP is set-up, even if your tech support is telling you otherwise.

Can you run phpinfo();? Provide a link to a phpinfo() script running on the server here so that we can look at your settings.



Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail

Annoyamouse August 30th, 2004 04:12 PM

Quote:

quote:Originally posted by richard.york
 Are both pages located on the same server with the same domain name?

Both are on the same domain

 
Quote:

quote:When you view the source of the second page is it completely blank, or does the PHP code appear in the source?

Completely blank

 
Quote:

quote:Can you run phpinfo();? Provide a link to a phpinfo() script running on the server here so that we can look at your settings.

Here's a link:
http://www.losspreventiongroup.com/phpinfo.php


richard.york August 30th, 2004 06:16 PM

Ok, your phpinfo says that the system is a Windows system, but the session.save_path directive of php.ini is a Linux file path. You should be seeing error output complaining about this.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail

Annoyamouse August 30th, 2004 11:17 PM

Nuh uh, I still don't see anything ...
I redid the files and you can try the link itself...
http://www.losspreventiongroup.com/Firstpage.php

I'd presume you'd get the same result when you click the link to otherpage.php - a blank screen ...:(

Man, this is frustrating ... Maybe instead of session variables I could just write the info to a temporary table in the mysql db I'm doing, yeesh ... :(


richard.york August 31st, 2004 12:04 AM

You still haven't changed the value of session.save_path to a valid Windows path.

phpinfo says: session.save_path /tmp /tmp

This isn't going to work on a Windows system, these are Linux file paths. So you need to supply the correct value. As for why you aren't seeing error output, you have the log_errors directive set to on and the display_errors directive set to off! So the errors are getting logged to a file leaving you clueless. All of these are php.ini settings, you can change ini values at run time with the ini_set function.

http://www.php.net/ini_set

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail


All times are GMT -4. The time now is 06:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.