WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : How to make sure a that $foo is from a cookie and not from the URI.
Categories : PHP, Variables, Global Variables, Cookies
Boaz Yahav
Date : Oct 05th 1999
Grade : Be the 1st to grade this Code Example
Viewed : 6442
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

If you base your actions about data from a cookie than you have a security whole.
Lets say that you want to let a user edit his/her details and you know who the user
is from a cookie you put on his computer. Now you assume that $user (just an example)
has the value you put there right? WRONG!!!!

If i go to the url and do http://www.MyDomain.com?MyScript.php3?user=berber

than $user will uave the value berber and if i do :

http://www.MyDomain.com?MyScript.php3?user=joe

than $user will uave the value joe which means that if you have a user
joe than i can see and edit his details.

What can you do?

Well, two things :

1. The simplest thing to do is check the URI :

$URI=getenv("REQUEST_URI");
If(strstr($URI,"user")) {
echo"This data is not coming from a cookie";
exit();
}


2. The more compex but more clean way of doing this is by using $HTTP_COOKIE_VARS["user"]
but In order for the various $HTTP_*_VARS[] arrays to exist, you need to turn
on track_vars. You can also turn track_vars on for a specific script by adding:
<?php_track_vars?> as the FIRST line of your script.

berber






Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with PHP 4.2.0
Categories : PHP, HTML and PHP, Global Variables, Cookies, Variables
getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
Initialize global variables for every field in a table. This version requires that phplib is installed on your server.
Categories : Global Variables, MySQL, PHP, Variables
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
Global Dump Highlighted
Categories : PHP, Variables, Global Variables
A flat file counter
Categories : PHP, Cookies, Filesystem, Beginner Guides
The following snippet gives complete info about all submitted HTTP_POST_VARS and HTTP_GET_VARS
Categories : Variables, HTTP, PHP
clearing variables in php3
Categories : Variables, Arrays, PHP
How to display a PHP variable value from a selectbox without reloading the page by merging PHP and Javascript variables.
Categories : PHP, Java Script, Variables
Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP, Directories, Variables, Arrays
translate.php - Assocciative array example, passing a reference to a function.
Categories : PHP, Arrays, Languages, Variables
This functions compares the current PHP version with a desired version. Because of the 3 tiered version system, a direct compare of a string to phpversion() will not be accurate.
Categories : PHP Configuration, PHP, Variables
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
cookie
Categories : Cookies, PHP
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
 tr909 dr ummachine wrote :408
yes, but maybe store a MD5($password) too in the 
cookie and then check it in those edit-pages against the 
database.