Hi Folks
I'm creating an intranet, and for once in my life I have decided to save every user's username and password in a cookie instead of passing argument to every script. However, I am running into problems.
This is a breakdown of my site, so far...
1. I have created a page for people to enter their login name and password.
2. Once they submit the details on the page above, they are taken to a login script which authorizes the user, and if authorization is correct, create a cookie of that user and password and then redirect to the main script.
3. main script, which should in theory grab the username and password from the cookie saved into the browser at the previous step.
My problem? It doesn't seem to want to save the cookie to my browser and/or I am retrieving it incorrectly.
This is the code I use to save my cookie into the user's browser:
$cookie_user = $query->cookie(-name=>'login',
-value=>"$A::login");
$cookie_pass = $query->cookie(-name=>'pass',
-value=>"$A::pass");
print $query->header(-cookie=>[$cookie_user,$cookie_pass]);
and this is the code I use to retireve my cookies in the main script:
$user_login = $query->cookie('login');
$user_pass = $query->cookie('pass');
Can anyone spot anything wrong with my code? Is there another, proven way to do this?
Any help would be appreciated.
Thank you
Wil Stephens
I'm creating an intranet, and for once in my life I have decided to save every user's username and password in a cookie instead of passing argument to every script. However, I am running into problems.
This is a breakdown of my site, so far...
1. I have created a page for people to enter their login name and password.
2. Once they submit the details on the page above, they are taken to a login script which authorizes the user, and if authorization is correct, create a cookie of that user and password and then redirect to the main script.
3. main script, which should in theory grab the username and password from the cookie saved into the browser at the previous step.
My problem? It doesn't seem to want to save the cookie to my browser and/or I am retrieving it incorrectly.
This is the code I use to save my cookie into the user's browser:
$cookie_user = $query->cookie(-name=>'login',
-value=>"$A::login");
$cookie_pass = $query->cookie(-name=>'pass',
-value=>"$A::pass");
print $query->header(-cookie=>[$cookie_user,$cookie_pass]);
and this is the code I use to retireve my cookies in the main script:
$user_login = $query->cookie('login');
$user_pass = $query->cookie('pass');
Can anyone spot anything wrong with my code? Is there another, proven way to do this?
Any help would be appreciated.
Thank you
Wil Stephens