•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,604 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,673 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1677 | Replies: 5 | Solved
![]() |
•
•
Join Date: Jun 2006
Location: College Station, TX
Posts: 35
Reputation:
Rep Power: 3
Solved Threads: 0
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
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 539
Reputation:
Rep Power: 3
Solved Threads: 54
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 503
Reputation:
Rep Power: 3
Solved Threads: 67
yeah,and try to echo the session to check if it exists
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Jun 2006
Location: College Station, TX
Posts: 35
Reputation:
Rep Power: 3
Solved Threads: 0
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.
session_start();
$_SESSION["authenticated"]
When I redirect back to the index page, it will not echo the authenticated or user_name variable.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 539
Reputation:
Rep Power: 3
Solved Threads: 54
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
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


Linear Mode