Re: POST losing SESSION vars?
| From: | bbonkosk at tampabay dot rr dot com | Date: | Tue, 09 Nov 2004 18:21:26 +0000 |
| Subject: | Re: POST losing SESSION vars? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-201638@lists.php.net to get a copy of this message | ||
Pass your session along with your form action...
i.e....
$s = SID;
echo "<form action=\".$_SERVER['PHP_SELF']."?$s\" method=post>
----- Original Message -----
From: Sam Smith <php@itab.com>
Date: Tuesday, November 9, 2004 1:12 pm
Subject: [PHP] POST losing SESSION vars?
>
> I have a page that will be redirected to a login page if the
> SESSION var
> 'authenticatedUser' is not set.
>
> The page has a form in it.
>
> When the page is loaded http://thePage the authentication works
>
> fine. When
> the submit button is pressed it doesn't. With POST it acts as if the
> required session var is not set.
>
> When redirected to the login page the login page DOES recognize
> the the
> session var and redirects back to the first page a logged in user
> wouldusually see.
>
> formPage.php
> <?php
> session_start();
> if(!isset($_SESSION['authenticatedUser'])) {
> $_SESSION['loginMessage'] = "You must first login.<br> ";
> header("Location: index.php");
> }
> ...
>
> <form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>"
> method="POST"name="purch_form" id="purch_form"
> ...
> <input name="Submit" ...
> </form>
> ?>
>
>
> index.php
> <?php
> // FUNCTIONS
> function logged_on($errorMessage) {
> header ("Location: authTest.php"); //tmp Loc while testing
> }
> function login_page ($errorMessage) {
> require_once "login.php"; //page where login pair entered
> }
> // end FUNCTIONS
>
> // BEGIN authentication
> session_start();
> // First visit
> if (!isset($_SESSION['loginMessage'])) {
> login_page("Registered users please login.");
> exit;
> }
> // PASS
> if(isset($_SESSION['authenticatedUser'])) {
> logged_on("need some control here");
> exit;
> }
> // FAIL
> else {
> login_page($_SESSION['loginMessage']);
> exit;
> }
> ?>
>
> In other words the same page should load after the submit button
> is pressed
> but instead the authentication is redirecting.
>
>
> Thanks for any help.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>