Page 1 of 1

Cookie Login

Posted: Fri Oct 08, 2010 10:21 am
by tazdaman
Hi,

I am trying to create a webpage which can only be accessed if a cookie containing the username and password is on the users system. If the cookie is not present the user is taken to another url. The way the cookie is placed on the users system is done by another webpage which writes the cookies and redirects the user to my page.

The way I would like it all to work is as follows

1) I create a button on my personal webpage saying click here to view secret files.
2) The link on the button takes user to 'temp.php' which writes a cookie to the users temp folder then redirects the user to my secret page called e.g. mypage.com
3) mypage.com checks if the cookie containing the username and password is present if not user is taken to google.com if is user is shown content.

Please let me know how to achieve this.

Re: Cookie Login

Posted: Mon Nov 22, 2010 5:00 am
by social_experiment
tazdaman wrote: 1) I create a button on my personal webpage saying click here to view secret files.
2) The link on the button takes user to 'temp.php' which writes a cookie to the users temp folder then redirects the user to my secret page called e.g. mypage.com
3) mypage.com checks if the cookie containing the username and password is present if not user is taken to google.com if is user is shown content.
1. Hyperlink is probably best (for this example)
2. Use 'setcookie()' to create the cookie / s
3. On mypage.com :

Code: Select all

<? if (!isset($_COOKIE['cookie_name']) // redirect user)
  else { // other code
  } ?> 
I don't think it's very secure though :|