Hi there,
Can we make the setcookie() time unlimited so that it lasts forever???? if yes, then how?
| SitePoint Sponsor |
Hi there,
Can we make the setcookie() time unlimited so that it lasts forever???? if yes, then how?


as far as i know there is a time limit, but you could try to set it again every time the user visits your site and thus extend the time.
Last edited by delpino; Oct 10, 2002 at 13:07.
Aha good idea delpino but this won't work since I want to prevent this visitor / user from registering in my forums again if he or she did it once.![]()
You can use the mktime() function in the lifetime argument of the cookie, and then set it for alomst unreachable dateOriginally posted by Ghz
Aha good idea delpino but this won't work since I want to prevent this visitor / user from registering in my forums again if he or she did it once.![]()
mktime(21,00,0,12,31,2004)
would set the cookie to expire at 9pm on the 31st December 2004
George




or, you could do it like normal people and just check if they try to register again against a list of usernames already taken and dont allow it.
PHP News, Views and Community: http://www.phpdeveloper.org
Can't argue with that, although I took it to mean that they wished to prevent them re-registering as another user.Originally posted by enygmadae
or, you could do it like normal people and just check if they try to register again against a list of usernames already taken and dont allow it.
George
Got Sig!


...And cookies can be deleted quite easilyAha good idea delpino but this won't work since I want to prevent this visitor / user from registering in my forums again if he or she did it once.
Luke
Luke-Martin.com (work in progress):: Independent Web Designer's Portal
Freelance Forums :: Sign Up Here
"What happens if you get scared half to death twice?"


then check for the uniqueness of the email address when they sign up.. that should do the trick
if you want to prevent that by cookie, what if 2 people who work on the same user what to have a separate account?
Last edited by delpino; Oct 10, 2002 at 13:08.
Sorry, but I failt o see hwo this is "unreachable".Originally posted by chiefmonkey
You can use the mktime() function in the lifetime argument of the cookie, and then set it for alomst unreachable date
mktime(21,00,0,12,31,2004)
would set the cookie to expire at 9pm on the 31st December 2004
George
December 31st, 2004 will come eventualy... or do they have to be active right at 9:00 PM? I didn't think so, but I could be wrong.
A truly unreachable date:
Now if your script is still running in 3004, I'll be amazedPHP Code:mktime(21,00,0,12,31,3004);
Besides, cookies will have been deleted by then anyways
(Either by the user, or completly wiped off the face of the net
)
- Nathan
Also, for matching:
Username's would never get duplicated, rarely. Generally the idea is to prevent people from signing up at like 10 different accounts. If they wanted to do this, they'd obviously signup with different usernames. E-mail is useless too, people will change it to some old@email.com address.
One of the best: Record IP in the user table, and e-mail, and username. Check to see if any one of them have been used.
A ligitiment (sorry, can't spell) user will see this about the e-mail and username, and will just login.
Somebody who knows about hte username, and e-mail, will bypass those, but the IP should catch them.
Now don't get at me that I'm stupid, I know.. IP's change when you disconnect and reconnect (for most people anyways). This simply prevents people from signing up right after the previous one: Who would go through the trouble to disconnect/reconnect just to signup again?
And the real user accidentally trying to re-signup, won't be able to with same IP, username, OR e-mail
Just me 2 cents..
Regards,
Someonewhois
- Nathan
I think it must just be me then, I don't think my machine would last over 2 years without needing reformated at some pointOriginally posted by someonewhois
Sorry, but I failt o see hwo this is "unreachable".
December 31st, 2004 will come eventualy... or do they have to be active right at 9:00 PM? I didn't think so, but I could be wrong.
A truly unreachable date:
Now if your script is still running in 3004, I'll be amazedPHP Code:mktime(21,00,0,12,31,3004);
Besides, cookies will have been deleted by then anyways
(Either by the user, or completly wiped off the face of the net
)
George
Got Sig!
Oh, well..... then the word "unreachable" isn't really suitable for this situation![]()
- Nathan


Try Linux. . .Originally posted by chiefmonkey
I think it must just be me then, I don't think my machine would last over 2 years without needing reformated at some point
George![]()
again, this will not work if two different people use the same machine that has a fixed IP address...Originally posted by someonewhois
One of the best: Record IP in the user table, and e-mail, and username. Check to see if any one of them have been used.
or, for instance, if they all come through a certain ISP's proxy - as their IP, as your site sees it, is the IP of the proxy, not the user's machine...(as far as i know anyway)
i think it's worth checking email address...anything beyond that really is a waste of time - imho - as there is NO secure way (unless we start using unique user tracking ... now, where's Palladium, TCPA and co. when you need them) to do it.
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
WaSP Accessibility Task Force Member
splintered.co.uk | photographia.co.uk | redux.deviantart.com
Sorry but users can make thousands of accounts and register every time with a new one. Or he/ she may make a new email account just to register with.Originally posted by redux
i think it's worth checking email address...anything beyond that really is a waste of time
Most of the users won't notice that they have a cookie set in thier machines other than the username and the password, thus they won't delete it. I think the best way is to setcookie in thier machines, check the IP's, Check the email, and also check the user name as well. These steps won't take a second from the secript to check them all but finally we will reduce the number of re-registerations.![]()
Do you buy this??
Bookmarks