cookie
hi anyone could help me to make a cookie system
i am using phpSecurePages to password protect my site with
but is it not possible to make the php schript make a cookie so the user are able to get in without typing he's uasername and password every time?
i am using the php script from this page
http://64.28.67.35/appindex/2000/05/29/959574524.html
with ex. a checkbox so the people can deside if they want to use the cookie or not
[Edited by raiden on 09-10-2000 at 01:10 AM]
Mark Hensler posted this at 23:20 — 10th September 2000.
He has: 4,048 posts
Joined: Aug 2000
I don't have time to write the whole thing out, but here is the syntx for a cookie..
setcookie("CookieName", "Value", "TimeUntilExpire");
snippet from my site:
if (isset($NewUserName)) { // User name
setcookie(UserName, $NewUserName, time()+(60*60*24*365));
}
There are more parameters, but they are not necessary. This cookie expires in one year.
You need to set one cookie for each variable you want to save on the visitors machine. The name of the cookie will the the name of the variable next time they visit.
in the HTML, you'll want something like:
<input type=text value="<? if (isset($UserName)) echo $UserName; ?>">
Good luck,
Mark Hensler
If there is no answer on Google, then there is no question.
Mark Hensler posted this at 23:22 — 10th September 2000.
He has: 4,048 posts
Joined: Aug 2000
you can read more about setcookie here:
http://php.net/manual/function.setcookie.php
123finder.com posted this at 04:23 — 13th September 2000.
They have: 60 posts
Joined: Aug 2000
But don't rely on cookies since the user could turn them off
If your host supports php4, use session management, which is very easy and basically it does use cookies (and other methods too!)
http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr
http://www.ad-rotator.com/ - Free ad rotating system for small websites - Stop Ctrl-P/Ctrl-C the ad code!
------
Son
Mark Hensler posted this at 05:29 — 13th September 2000.
He has: 4,048 posts
Joined: Aug 2000
session are nice (and at times, life-savers), but I don't think they'd be of help here.
If a user signs up and get a username/password. then closes his browser, the session is lost. Cookies are the only alternative. And if the user has cookies turned off, they have no choice but to type and re-type the info.
Mark Hensler
If there is no answer on Google, then there is no question.
Mark Hensler posted this at 05:31 — 13th September 2000.
He has: 4,048 posts
Joined: Aug 2000
forgot to mention...
any cookies you set in PHP are only accessable to PHP pages. This means that you may have to convert many of your pages to PHP. If you do this, be sure to double check your links!
Mark Hensler
If there is no answer on Google, then there is no question.
gokhan posted this at 09:09 — 13th September 2000.
They have: 3 posts
Joined: Sep 2000
sessions last 20 minutes if i am not wrong. and do not trust sessions.
123finder.com posted this at 20:34 — 13th September 2000.
They have: 60 posts
Joined: Aug 2000
Notice that session is NOT lost when you/ your visitors close the browser!
And yes, I think it would expire after about 15-20mins (I don't know exactly, just about that)
You could use session management and specify the method is cookie instead of temp files, db,...
http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr
http://www.ad-rotator.com/ - Free ad rotating system for small websites - Stop Ctrl-P/Ctrl-C the ad code!
------
Son
Mark Hensler posted this at 05:17 — 14th September 2000.
He has: 4,048 posts
Joined: Aug 2000
so... if the user closes their browser, and comes back within time, how does the server know what session to match it with?
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.