| | |
Session variables not carrying over to next page
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Howdy all,
I'm making an authentication script using sessions variables, but the varible seems to disappear when trying to access it from another page.
A simple form on the home page takes a user name and password, it then goes to an authentication page. The authenticate page is making a match and setting the session variables. I have tested this part and know that for sure. The authentication page then redirects in 2 seconds back to the originating page by a meta refresh. In this case, its the index page, but the index page does not recognize the session variable. Here is the code on the index page:
It supposed to acknowledge the user, or put the log in form on the page, but it doesn't recognize the varible. Can anyone help? I've googled and looked at the code over and over, but can't see anything wrong.
Also, I'm using PHP 4.2.?, so I should not have to register the session variables as recommended for version 4.1 and above, correct?
Thanks,
Gil
I'm making an authentication script using sessions variables, but the varible seems to disappear when trying to access it from another page.
A simple form on the home page takes a user name and password, it then goes to an authentication page. The authenticate page is making a match and setting the session variables. I have tested this part and know that for sure. The authentication page then redirects in 2 seconds back to the originating page by a meta refresh. In this case, its the index page, but the index page does not recognize the session variable. Here is the code on the index page:
if ($_SESSION["authenticated"]=="YES")
{
echo "Hi " .$_SESSION["user_name"];
}
else
{
?>
HTML form code here.
<?php
}
?>
It supposed to acknowledge the user, or put the log in form on the page, but it doesn't recognize the varible. Can anyone help? I've googled and looked at the code over and over, but can't see anything wrong.
Also, I'm using PHP 4.2.?, so I should not have to register the session variables as recommended for version 4.1 and above, correct?
Thanks,
Gil
Yes, I did have the
and it does show the session variables on the authentication page when I echo the
variable. It returns 'YES', so I know its making the query on the mySQL database and matching with the submitted data.
When I redirect back to the index page, it will not echo the authenticated or user_name variable.
PHP Syntax (Toggle Plain Text)
session_start();
PHP Syntax (Toggle Plain Text)
$_SESSION["authenticated"]
When I redirect back to the index page, it will not echo the authenticated or user_name variable.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- shopping cart and payment gateway (ASP.NET)
- Session variables (ASP.NET)
- PHP Session Variables (PHP)
- Session Variables a threat? (VB.NET)
Other Threads in the PHP Forum
- Previous Thread: Coloring text
- Next Thread: session variable error
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube






