Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing last viewed page in Cookie and encrypt 1

Status
Not open for further replies.

namida

Programmer
May 29, 2003
101
0
0
AU
1. What is the best way to store the last viewed/clicked page in a cookie?

Do I have to put a setcookie in every page?

2. How do I sort of encrypt the values of the cookies? Most cookies that I saw in my computer doesn't make sense at all but if I put something like setcookie("loginname","theloginname") I don't think that's pretty safe ?

 
If your client has his browser configured to do so, you can use $_SERVER['HTTP_REFERER'] to find out the previous page. It's not necessary to set a cookie to do so.

However, some browsers allow the user to turn off referer logging. You might try setting the current page name in a cookie in every page.


In terms of encrypting cookies, you can. But you could also use session variables. PHP's session handling mechanism sets a single cookie with an ID string, then uses that ID string is successive pages to fetch the data for all your variables from a datastore. That datastore is by default a place on your hard-drive, but can be changed to other sources, such as a database backend.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Alright. thanks
I think I might stick to sessions then.
I probably would do something like 'the last 5 companies you have viewed'

Now I'm wondering why People use cookies at all.

I heard there's a hole in IE where other sites can actually read cookies from other sites (I heard this from another site who then incorporate people to login twice once the normal way and once by using a pop up)

Anyone has any point of view in this matter?
 
So I think that to have 5 last pages I should
make a loop with every page and
move each element of a last[] array ?

So when I click the next page the previous page is moved to the [1] while the current page is at [0] ..
up until 4.. and goes on.

Is this the most efficient way?


 
A note to anyone who's trying to do something with $_SERVER['HTTP_REFERER'] I don't know if it's just my dreamweaver

But if you're using Dreamweaver MX and use the shortcut function where you just type $_SER and enter and it will type $_SERVER for you

For the list of variables.. when you choose ['HTTP_REFERER'] on the list the actual print in your document would be ['HTTP_REFERRER'] with double R.

It took me a short while trying to figure out why the variable did not print out.

I tried it a few times and although the select option is only 1 R when I enter it's 2 R.

Anyone having the same experience?

Do I make sense at all?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top