Reply to Re: my session variables aren't lasting when posting to SELF

Your name:

Reply:


Posted by Oli Filth on 09/13/05 16:24

google@charliefortune.com wrote:
> My login.htm takes the value (a password) of a textfield and POSTS it
> to page2.php. This works correctly.
>
> The first thing Page2.php does is start a session, put the password in
> it, then open a MySQL database, and insert various values (which start
> off NULL) and then closes the connection. Following this, an HTML form
> is displayed and the user enters values. This form is POSTed to itself
> (no 'action') and the idea is that the php at the head of the page will
> run the SQL query again with the new values. Unfortunately, on
> reloading the page, my $_SESSION['pass'] variable has nothing in it.
>
> the relevant code looks like this ;
>
> <?php
> session_start();
> $_SESSION['pass']=$_POST['pass']; //posted from login page
>
> ......
> $pass=$_SESSION['pass']; //turn it into var for MySQL
> query
>
> ?>
>
> The first time I get to this page, via login page, it works correctly
> because the password is posted. When it rePOSTs to itself however, the
> $_SESSION['pass'] remains empty.

Two things to check:

* Is there any character output in page2.php before the opening <?php ?
This includes *any* whitespace, newlines, etc. If there is, then
session_start() will not work correctly (or at all).

* Do you have cookies enabled on your browser? Check in your browser's
cookie list whether you're getting a PHPSESSID cookie from the domain
your script is running on.


--
Oli

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация