php5 user authentication and remember me function

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
markthien
Forum Commoner
Posts: 33
Joined: Fri Feb 13, 2009 7:50 pm

php5 user authentication and remember me function

Post by markthien »

Hi guys,

I guess you guys will laught at my azz. I jus started using php like 2 months ago. I was developing web applicationusing java using appfuse framework. I need to find an example for implementing user authentication and remember me function. Can anyone give me show where can i get those info.

I have seen some example where after user has been authenticated, they set a flag to 1 like below:

session_start();
$_SESSION['authenticated'] = 1;

or some even just set the username in the session like

$_SESSION['username'] = 'markthien';

so in every secure pages which they just check if the session variable is set like below:

if (!isset($_SESSION['username']) {
// redirect to login page
} else {
// display the secure page
}

I am just wondering is this a proper way or secure way to check if user is logon? is it possible for some hacker to like change the 'authenticated' session variable to 1 then they don't even need to login and able to access the secure page?

appreciate any help please.

thanks & regards,
Mark
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: php5 user authentication and remember me function

Post by Benjamin »

Please use the appropriate

Code: Select all

 [ /code] tags when posting code blocks in the forums.  Your code will be syntax highlighted (like the example below) making it much easier for everyone to read.  You will most likely receive more answers too!

Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces.  You can even start right now by editing your existing post!

If you are new to the forums, please be sure to read:

[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]

If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online.  You'll find code samples, detailed documentation, comments and more.

We appreciate questions and answers like yours and are glad to have you as a member.  Thank you for contributing to phpDN!

Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]
Post Reply