| | |
How to save session values in JavaScript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2006
Posts: 6
Reputation:
Solved Threads: 0
There are more ways to do it than just cookies - it basicaly depends if you want to store the session between visits that happend at the same time, or if you want to save sessions for later use.
If the later is what you want, go for cookies:
If you just want to save the session while the user leaves your pages you could use a hidden frame and store the session value inside a hidden input.
If the later is what you want, go for cookies:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); }
If you just want to save the session while the user leaves your pages you could use a hidden frame and store the session value inside a hidden input.
![]() |
Similar Threads
- Save the values of a form (HTML and CSS)
- need help with session values (ASP.NET)
- Save form values - show/hide divs depending on values (JavaScript / DHTML / AJAX)
- Access hidden values by javascript (PHP)
- Hi how to store arraylist values in session state (ASP.NET)
- How to pass the values of javascript in perl (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Request for javascript based editor
- Next Thread: AJAX : Am i right with the concept?
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets array autoplay blackjack browser captcha captchaformproblem cart child class close codes date debugger dependent developer disablefirebug dom editor element embed engine enter events explorer ext file firefox flash focus form forms frameworks game gears getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe java javascript javascripthelp2020 jquery jsf jsp jump libcurl maps marquee masterpage math media menu object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player position post programming prototype rated redirect safari scale scriptlets scroll search security size software solutions sources star stars stretch synchronous toggle tweet unicode variables web webkit webservice window \n






