WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : cookie
Categories : Cookies, PHP Update Picture
Jeff Schmitt
Date : May 07th 1998
Grade : 2 of 5 (graded 4 times)
Viewed : 23409
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Jeff Schmitt
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?
// cookie.php3
//
// by Jeff Schmitt
// Towson University
// March, 1998
//
/*
Date: Wed, 8 Apr 1998 01:51:04 -0400
From: "Brian M. Platz" <platz.brian@infoband.com>

The syntax is:

SetCookie($name,$value,$expire_time,$directory,$domain,$secure);
$name - name of the cookie

$value - value of the cookie

$expire_time - [optional] time in UNIX epoch seconds when cookie should
expire. This is optional, and if not specified will expire after
the user 'session', or after they exit your domain/directory
specified.

$directory - [optional] directory under web server this cookie is for.
Defaults to the directory of the requested page.

$domain - [optional] domain name this cookie can be used under.
Defaults to domain name of requested page. Must have TWO '.' in the
name, so if you specify your A level, you must use ".mydomain.com"

$secure - [optional] if set to '1', this cookie will only be sent over
secure server, or an 'https://' request.

if your document is /mydir/index.php3 and you set a cookie using
SetCookie("mytest", "this is a test cookie");
you will only be able to access $mytest for document under the /mydir/
directory tree.

To set a cookie that will expire after the current session, and will work
for your entire domain.. use the following:
SetCookie("mytest", "this is a test cookie", 0, "/", ".yourdomain.com");

As for retrieving the value of a cookie, it is automagically URL decoded
and put in a variable.

As for "if (!SetCookie("mytest", "this is another test")) {",
I don't think SetCookie() returns a value. I could be wrong.

-Brian Platz

*/

// This code must go before the HTML header has been sent
// in other words it preceedes all echo and <HTML> code

// we increment a hard-coded cookie variable: $cookiecount
SetCookie("cookiecount", ++$cookiecount, 0, "/", ".towson.edu");


// look at the HTML form variables
if ($action) {
// set the cookie variable
// append "cookie" to name of the variable
// so it can easily be found in list of global variables
SetCookie("cookie".$name, $value, 0, "/", ".towson.edu");
echo "<P>Setting Cookie: $name to $value<BR>\n";
echo "(reload this form to see if this value is reported)\n";

}

?>
<HTML><HEAD>
<TITLE>cookie test</TITLE>
</HEAD>
<BODY>
<H2>cookie test</H2>

<?
echo "<P>Reporting your cookies:<BR>\n";
while (list($key, $value) = each($GLOBALS)) {
if (ereg('cookie',$key)) {
echo "$key: $value<BR>\n";
}
}

?>

<HR NOSHADE>
<H3> Set some cookie values: </H3>
<FORM METHOD="POST" ACTION="<?echo $PHP_SELF;?>">
<TABLE BORDER=1>
<TR><TH>Name:
<TD><INPUT NAME="name" size=8 MAXLENGTH=8>
<TH>Value:
<TD><INPUT NAME="value" size=30 MAXLENGTH=30>
<TR><TH>Action:
<TD><INPUT TYPE="SUBMIT" NAME="action" VALUE="Submit">
<TD><INPUT TYPE=RESET VALUE="Clear Form">
</TABLE>
</FORM>
</BODY>
</HTML>



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
The Best Authorize
Categories : PHP, MySQL, Cookies
Secure Login
Categories : PHP, MySQL, Cookies, Security
Simple Cookie example
Categories : PHP, Beginner Guides, Cookies
Cross Browser Session Starter
Categories : PHP, Sessions, Cookies
With this class you can use cookies with chips
Categories : PHP, Cookies
Function that does language negotiation based on the Accept-Language header, a cookie or host name
Categories : HTTP, PHP, Cookies
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
A flat file counter
Categories : PHP, Cookies, Filesystem, Beginner Guides
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
PHP Cookies - Simple cookie write/read methods that allow basic encryption
Categories : PHP, Cookies, Security, Encryption
Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases
Multilingual php webpage
Categories : PHP, Languages, Cookies
cookie permanence
Categories : Cookies, PHP
Smart Counter - This little script is a plain and simple hit counter that uses cookies to determine whether or not the visitor has already been counted.
Categories : Cookies, HTML and PHP, PHP