PHP session problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
systemphp
Forum Newbie
Posts: 3
Joined: Sat Jul 19, 2003 8:30 pm
Location: US

PHP session problem

Post by systemphp »

:cry: Need help!

I tested my PHP codes on my home linux box, they all worked fine. But they don't work on my hosted website.

I have Sessions in my code. I need search, login, and shopping cart function. Home page works with PHP/MySQL, but buttons like search, login don't work (blank page with PHPSESSID=****** in the URL). Strange is I can load my login.php and search.php directly, but again buttons in these page don't work and only give blank page.

I guess I have session problem.

Can anyone give me some hints? How to setup or write sessions in this case?

Thanks in advance!
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

WHat version of PHP at home and what version at your webhost?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What session information do you get if you put a script with

Code: Select all

<?php phpinfo(); ?>
in it on the web host?

Mac
systemphp
Forum Newbie
Posts: 3
Joined: Sat Jul 19, 2003 8:30 pm
Location: US

Post by systemphp »

Thank you all!

Webhost: PHP 4.3.1
max_input_time -1
register_globals on
y2k_compliance off

My Linux: PHP 4.3.0
max_input_time 60
register_globals off
y2k_compliance on

I only see these differences. I can get ride of PHPSESSID by adding ini_set('session.use_trans_sid', false);
but it still doesn't work.

This is what in the browser URL window: http://www.***.net/buttons.php?search=Search

Blank in brower.

In the buttons.php I have:
header("Location:search.php?{$_SERVER["QUERY_STRING"]}");
It doesn't redirect to search.php?!

I tested <?php header("Location:search.php?{$_SERVER["QUERY_STRING"]}"); ?> in a seperate file, and search.php did show up, but buttons on that page had same problem.

I still suspect PHP setting is the problem, but I don't know how to change it. I have a .htaccess file where I put my settings in.

Thanks again!
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

syntax for http header Location is

Location: url

the colon should have no space in front and one space after (It has never been any other way, although some say certain PHP version(s) behaved different, the http spec is now... And remember, you must urlencode the query string if it has any spaces or slashes or any non-standard letters..

Another comment, what is the purpose of that redirect? seems rather useless, a simple include would work, or perhaps a mod_rewrite rule ?
systemphp
Forum Newbie
Posts: 3
Joined: Sat Jul 19, 2003 8:30 pm
Location: US

Post by systemphp »

Thank you all!

The button php file might have problem, also the server PHP settings probably is a point too. After I contact with the hosting support, it works okay now.

Thanks again
Post Reply