Logging in, & sessions o_O
Moderator: General Moderators
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
Logging in, & sessions o_O
Q1: logging in
now, everything works pretty well, but I need to know a few things
how do I redirect to a new page with no event?
IE your at login page, your details are correct, and it instantly redirects you (on page loading) to "home" page
Q2: sessions, I get what they do, but i've been told to use them for logging in and stuff, but why? whats the point? what kind of things can you do with em other then counting pages lolz
now, everything works pretty well, but I need to know a few things
how do I redirect to a new page with no event?
IE your at login page, your details are correct, and it instantly redirects you (on page loading) to "home" page
Q2: sessions, I get what they do, but i've been told to use them for logging in and stuff, but why? whats the point? what kind of things can you do with em other then counting pages lolz
-
timclaason
- Forum Commoner
- Posts: 77
- Joined: Tue Dec 16, 2003 9:06 am
- Location: WI
Authentication
For redirecting, you can use
For sessions, you can use sessions for anything you would use a cookie for. Session settings, storing username on client side, etc. It's basically anything you want to keep on the client side.
One thing I use sessions for is to generate session ids.
PHP code is
session_id() generates a hexadecimal string that is unique. I can then stick that string into a database, and compare the database value to the client side value. I can check to see how long they've been logged in, or if they've logged in before. The sky is the limit, really.
Plus, I'm sure someone will post a good link to a page outlining how to uses $_SESSION[]
Code: Select all
Header("Location: pagename.php?anydesired=querystring");One thing I use sessions for is to generate session ids.
PHP code is
Code: Select all
session_id();Plus, I'm sure someone will post a good link to a page outlining how to uses $_SESSION[]
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
ok
that'd be good thanks ^_^
also getting a header error
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\mythic aeons\action=login.php:4) in
hmm?
also getting a header error
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\mythic aeons\action=login.php:4) in
hmm?
Code: Select all
if ( false!== $userdata)
{
sleep(5);
Header("Location: Home.php");
}
else
{
echo "your not registered";
}-
timclaason
- Forum Commoner
- Posts: 77
- Joined: Tue Dec 16, 2003 9:06 am
- Location: WI
Error
For header to work, output_buffering needs to be on in php.ini. Or you can do ob_start() in your code, just before the Header.
PHP freaks if there's already been page output before the Header("Location:..."). So, it's best to not output any HTML, etc on your page prior to doing the redirect.
PHP freaks if there's already been page output before the Header("Location:..."). So, it's best to not output any HTML, etc on your page prior to doing the redirect.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Re: Error
output buffering is a band-aid approach to the problem, it's not a solution.timclaason wrote:For header to work, output_buffering needs to be on in php.ini. Or you can do ob_start() in your code, just before the Header.
PHP freaks if there's already been page output before the Header("Location:..."). So, it's best to not output any HTML, etc on your page prior to doing the redirect.
viewtopic.php?t=1157
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
...
Erm, that makes it harder to see how I could do anything -.-
like, how could I possibly
check if the username & password doesnt match,
"Display error"
if it does match
(redirect to Home.php)
it doesnt make sense:/
like, how could I possibly
check if the username & password doesnt match,
"Display error"
if it does match
(redirect to Home.php)
it doesnt make sense:/
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Might I suggest you search the forums/google/PHP.net for information regarding what you want to do. A lot of what you are asking are commonly asked, new-to-PHP type questions that I am sure have been answered before. Try some stuff, post some code, search for answers. Before asking the question, please.