The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Cookies
Discuss Cookies in the PHP Development forum on Dev Shed. Cookies PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 20th, 2000, 07:43 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
In short: How do cookies work?
In long:
I want to set a cookie as a user logs into the system, i want the cookie(or cookies) to hold his username and password, then i want him to be able to go where ever without having to re-enter his username/password either untill he logs out, or his cookie expires..
any suggestions?
------------------
-Mike
Thanks for any help
[url]http://209.161.8.36/
|

May 21st, 2000, 07:26 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Here is some example code I've whipped together for you....
<?
if($action == "setcookie") {
setcookie("vis_name", $visitorname, time() + 3600);
// expires in one hour
}
if (isset($vis_name)):
// if cookie is set, display it
?>
<font face="Verdana" size="1">
<b><center>
<?
$msgline = "The Company welcomes " . $vis_name . "!";
print("$msglinen");
?>
</b></center>
</font>
<? else: ?>
<div align="center"><center>
<font face="Verdana" size="1">
Personalize Your Company! [Enter Name Below]<br>
<form><b>
<input type="hidden" name="action" value="setcookie">
<input type="text" name="visitorname" size="15" value="Insert Name" tabindex="1" maxlength="35">
<input type="submit" value=" OK! " tabindex="2">
</font></b></strong>
</form>
</div></center>
<? endif; ?>
Hope this code is a little help on what cookies are all about, and if you want, stop on over to http://evilwalrus.com and check it out, we offer tons of free scripts (user submitted) and I've implemented my little "cookie system" on my site, just to spice things up a bit...
------------------
Evil Walrus
AKA: Andrew Heebner
|

May 21st, 2000, 05:41 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Ok, cookies i understand now, i was up till 3am writing my little script, it's up to about 500 lines now, uhm..one thing, how would i make a cookie set for a ip address domain, e.g. 10.1.1.1
cuz, i dont exactly have a domain name for my server yet...
|

May 21st, 2000, 08:23 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I don't have a clue how to use cookies for IP address's.. probably something along these lines....
<?
$server = "10.1.1.1";
setcookie("COOKIE_NAME", $cookie_val, $server);
?>
I really don't have a clue on this one... lets leave it to these BrainDump braniacs URL
------------------
Evil Walrus
AKA: Andrew Heebner
|

May 22nd, 2000, 01:12 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
well, that does'nt work, i know for a fact, i've tried that already hehe  , if we must, for now i just have vhosts setup with apache on my server both pointing to the same ip, so it covers both my hostnames  ..just, alotta extra work involved there..oh well, it's off to formatting the HTML to make the site look perty
|

May 22nd, 2000, 02:38 AM
|
 |
.Net Developer
|
|
Join Date: Feb 2000
Location: London
Posts: 987
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
|
|
# the following will set the cookie in the root directory of your domain(you can replace that with ipnumber).
setcookie("vis_name", $visitorname, time() + 3600,"/","www.yourdomain.com","");
------------------
SR -
shiju.dreamcenter.net
"The fear of the LORD is the beginning of knowledge..."
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|