| | |
log in script saves cookie
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2006
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by tgreer
You can certainly write cookies with JavaScript, yes. A simple web-search should reveal hundreds of examples. You can also use the JavaScript "timer" object to periodically check to see if a cookie has expired. So yeah, this could be done. However, it won't be secure.
can this be done?
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Yes, it can be done, using the techniques I've already described. What specifically have you tried? At what point does it fail? You need to show us what you've already tried, what you already know, so we can help you properly.
As I said, there are lots of examples of how to read/write cookies with JavaScript, and the other object you'll need is the "timer" object.
As I said, there are lots of examples of how to read/write cookies with JavaScript, and the other object you'll need is the "timer" object.
•
•
Join Date: Feb 2006
Posts: 4
Reputation:
Solved Threads: 0
Sorry, I did not make myself clear. I have been reading up about cookies, I can understand the principles behind how they work, however Im totally new to actually writing code, Im afraid I cant string 2 variables together for trying. I did try a cookie script but It didnt do anything at all. What Im asking is if you could please draft something like this, explaining where I should add/modify parts so I can work from it. I havent been able to find examples of such a cookie script.
Im just asking for an example roughly suited to the purpous I want, Ie to remain active session, so when a member closes the browser, they are not logged off but can return later (if not indefinate period atleast up to a few days later) and still be logged in provided they dont delete their own cookies. ?
Im just asking for an example roughly suited to the purpous I want, Ie to remain active session, so when a member closes the browser, they are not logged off but can return later (if not indefinate period atleast up to a few days later) and still be logged in provided they dont delete their own cookies. ?
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Ok. I'll try to help, if you try to use apostrophes in your posts. Deal?
You set cookies using the "document.cookie" object. The arguments are name-value pairs:
Three pairs: the cookie name and value, the expiration date-time, and the path.
To read the cookie:
Try that, make sure you can at least write and read the cookie. You do know how to at least create an HTML document with scripts, right?
You set cookies using the "document.cookie" object. The arguments are name-value pairs:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
document.cookie = 'cookieName=cookieValue; expires=Thu, 23 Feb 2006 20:47:11 UTC; path=/'
Three pairs: the cookie name and value, the expiration date-time, and the path.
To read the cookie:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
var x = readCookie('cookieName') if (x) { [do something with x] }
Try that, make sure you can at least write and read the cookie. You do know how to at least create an HTML document with scripts, right?
Last edited by tgreer; Feb 23rd, 2006 at 12:21 pm.
![]() |
Similar Threads
- document.write according to log-in cookie present / absent (JavaScript / DHTML / AJAX)
- send mail after script finishes running (Shell Scripting)
- ...Not sure where the problem lies... (Web Browsers)
- url redirects to yahoo.com (Windows NT / 2000 / XP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Problem in hovering
- Next Thread: Page Loading
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxhelp animate api automatically beta boarder box bug calendar card checkbox child class column cookies createrange() css cursor decimal design dom download dropdown editor element error events explorer file firehose flash form forms google gwt html htmlform ie8 iframe image() images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jump listbox math matrixcaptcha microsoft mimic mp3 mp4 mysql object onmouseoutdivproblem onmouseover onreadystatechange parameters parent passing php player post problem progressbar rating regex runtime search select session shopping size sql star starrating stars stretch text textarea twitter validation w3c web website window windowofwords windowsxp wysiwyg xml xspf \n






