Well, since i started learning php, I become familiar with session.
But noticed that it is not very user friendly and secure...
Like, on a shared server, other people can steal session file.
Anway, i did not seey any good secure user authentication in session other then the following logic
<?php
session_start();
if(!isset($_SESSION["myvariable"])){
tell the visitor to login
}else{
ok, there is session now check this session against database.if everything ok, let the secure page to access
}
?>
And the big problem is .. to track user ,I wil l have to start session.. in any place that I want o check access
and If i start session I will get problem in form submissoin.Cause
Once the user submitted a form and if they go back to fill up incomplete fields of the form it's previously filled fields content disappear. It's annoying ..because customer wasted time to fill up a form and for just one mistake he has to rettype everything.
so, what the soluation for me. I give you one example bellow here
<?php
//login page
session_start();
if(isset($_SESSION["logged_in"])){
header("location:index.php?file=member");
exit;
}
echo"<form action=\"check.php\" method=\"post\">";
echo"Your message <textarea name=msg col=51 rows=8></textearea>";
echo"Your name<input type=\"text\" name=unmae>";
echo"<input type=submit value=send message>";
echo"</form>";
?>
Now here is my check.php
<?php
if(empty($_POST["name"])){
echo"OOPs, you didn't write your name";
exit;
}
You can see that if the use forgot to type thier name he has to go back to login page and type his name. But as i started session,
user has to retype his message !
Anway, solution...
I want to use cookie but ..session is more simpliar...
Any suggestion or solution ..
Thanks