Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 25th, 2004, 11:22 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?

Reply With Quote
  #2 (permalink)  
Old August 25th, 2004, 04:16 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
Reply With Quote
  #3 (permalink)  
Old August 26th, 2004, 04:34 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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)...

Reply With Quote
  #4 (permalink)  
Old August 26th, 2004, 09:04 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
Reply With Quote
  #5 (permalink)  
Old August 30th, 2004, 03:00 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

Reply With Quote
  #6 (permalink)  
Old August 30th, 2004, 03:11 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
Reply With Quote
  #7 (permalink)  
Old August 30th, 2004, 04:12 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #8 (permalink)  
Old August 30th, 2004, 06:16 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
Reply With Quote
  #9 (permalink)  
Old August 30th, 2004, 11:17 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ... :(

Reply With Quote
  #10 (permalink)  
Old August 31st, 2004, 12:04 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Variables in C# shikha09 C# 1 November 28th, 2006 10:38 AM
Session Variables testsubject Visual Studio 2005 8 March 8th, 2006 04:26 PM
Is it possible for me using session variables into see07 ASP.NET 1.x and 2.0 Application Design 4 March 9th, 2005 07:46 PM
Session Variables flesh_god Dreamweaver (all versions) 7 November 11th, 2003 05:52 PM
session variables help face Classic ASP Databases 4 September 12th, 2003 03:57 PM



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


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