using a php passwprd script

alvito

New member
Apr 22, 2011
100
0
0
i have a php password script for a photos page of mine. but i want to use the cookies thing. such that if a person is visiting the photos page for the first time, he is automatically redirected to the password page first to log in.

else he could simply visit Xxx.com and the password page would never kick in at all, so no use of it... how can i ensure that if a person is visiting the photos page for the first time, he is automatically redirected to the password page first to log in.
 


Have you broken this down into pseudo code? It's a pretty straightforward and commonly asked question with almost 10 million results for "php check for session or cookie". People tend to think it's a bigger issue than it is, but if they just broke it down into pseudo code it becomes very simple.

Code:
if cookie or session is set
	redirect to page
else set cookie and session
	redirect to login page

I suggest you check out this link, because it has many of the same elements you're looking for.
web development - Check session and cookie not working in PHP - Stack Overflow
 
yea, i used the pseudo code, still it wasnt of much use. took me ages to understand how to getr the setcookies to work and stuff, but i finally managed. the only problem now is that i want the setcookies expiry to update itself based on the user's last activity, and not since the initial time he logged on.

The update script for my setcookies does not seem to work. Kindly help me out guys.

i have the following in my header.tpl(smarty file) placed right at the beginning
{php}
//Start the session
session_start();

//Call the functions file
require_once("templates/b/functions.php");
//Display either the user's name, or the login form
//This can be placed on many pages without having
//to re-write the form everytime, just use this function
loggedIn();
{/php}


as you can see it calls the functions.php file which is the image below. i'm concentrating on the else portion. The browser prints out johnny and the expiry timestamp, but the bloody cookie doesnt update itself to "johnny".. why???????