PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 20th, 2000, 07:43 PM
splaq splaq is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 5 splaq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to splaq
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/

Reply With Quote
  #2  
Old May 21st, 2000, 07:26 AM
Evil Walrus Evil Walrus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 2 Evil Walrus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Evil Walrus
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

Reply With Quote
  #3  
Old May 21st, 2000, 05:41 PM
splaq splaq is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 5 splaq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to splaq
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...

Reply With Quote
  #4  
Old May 21st, 2000, 08:23 PM
Evil Walrus Evil Walrus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 2 Evil Walrus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Evil Walrus
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

Reply With Quote
  #5  
Old May 22nd, 2000, 01:12 AM
splaq splaq is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 5 splaq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to splaq
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

Reply With Quote
  #6  
Old May 22nd, 2000, 02:38 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

# 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..."

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Cookies

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap