Forum Moderators: mack

Message Too Old, No Replies

Cookies and Protected Pages

         

Saboi

3:19 pm on Sep 12, 2007 (gmt 0)

10+ Year Member



Hi guys,

I am trying to use cookies to protect specific pages on my site.

Let me give the situation...

Person logs in

If password wrong, they are directed to a registration page. If correct to specific pages. I set a cookie at this stage.

I would like to use the cookie on other pages and so call upon it, this works well.

The client can then browse through the site and logout when they finish. At this stage the cookie is destroyed.

The problem is when i type the url to any one of the pages i would like protected, it goes throuhg and displays content.

How can i avoid this?

Please advice.

Saboi

justgowithit

6:41 pm on Sep 12, 2007 (gmt 0)

10+ Year Member



Sounds like you're either not destroying the cookie or you're not validating the user on all pages.

Which language are you using?

piatkow

12:38 pm on Sep 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Some guesses

1. You aren't checking for the cookie on all pages
or
2. You aren't deleting it on all exit actions
or
3. You check for the cookie but don't actually act on the result.

Saboi

4:27 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



Hi guys,

Thanks.

I am using PHP.

When a user successfully logs in, a cookies is created which is repeated on every page.However when i type the full url in the address bar for anyone of the "protected" files, it takes me straight to that path.

Please advice what i could be doing wrong.

Saboi

justgowithit

6:14 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



When you say
a cookies is created which is repeated on every page

do you mean you're actually creating a new cookie on each page? If so, that may be your problem.

Have you considered using sessions instead of cookies for your authentication? That way you wouldn't have to check the cookie just a session variable.

Saboi

3:31 pm on Sep 23, 2007 (gmt 0)

10+ Year Member



Hi,

Tried sessions and just made a posting under the php forums. Please do check and assist me where i have gone wrong. My script is working but i am not getting the desired results.

Saboi

encyclo

3:38 pm on Sep 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Continued here: [webmasterworld.com...]