Ramesh Lamani
Ramesh Lamani

Reputation: 1127

IE9 cookies not working once browser is close and open?

i Have done application using Extjs 4.1. Have login page with remember me option. Here we are storing the remembered user information in cookie using java script, Once the use login the application with remember me option, his information will be storing in cookie till 7 days from date of login. This feature is working very fine in all browser except IE9. In IE9, if i login with remember me option, it will remember till i close the application. once i closed and open the browser next run the application. It is not remembered me. but when i visited developer tools-> view cookie information, it contains my login information. next again i reloaded the application remember me is working. Again i have closed browser and opened remember is not working without opening developer tools. if i open developer tools option and reload application remember me working. Why should i need to open developer tools each time whenever i close the browser. Can any body tell me how to resolve this issue? any IE9 browser setting problem? Great appreciated. Thank you.

Here is my code:

                        var check = Ext.getCmp('chkBoxId').getValue();
                        var username = Ext.getCmp('userId1').getValue();
                        var Password = Ext.getCmp('paswordId').getValue();
                        if(check==true)
                        {                                
                            var now = new Date();
                            var time = now.getTime();
                            var expireTime = time + 604800000//1000*36000;
                            now.setTime(expireTime);
                            var tempExp = 'Wed, 31 Oct 2012 08:50:17 GMT';
                            document.cookie = 'AddedCookie='+username+'/'+Password+'/'+check+';expires='+now.toGMTString()+';path=/';
                        }
                        else{
                            document.cookie = 'AddedCookie='+username+'/'+Password+'/'+check+';expires='+new Date()+';path=/';
                        } 

Upvotes: 0

Views: 418

Answers (2)

Neil McGuigan
Neil McGuigan

Reputation: 48246

You shouldn't be using javascript with your login cookie.

Use SSL, and useSSL-only cookies.

Create the cookie on the server, with the HTTP-only flag.

Store an authentication ticket in the cookie, not the password.

Don't store the user's password in your database, store a salted hash.

Otherwise, for cookies, you can try http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.util.Cookies to make it easier.

Upvotes: 1

Ramesh Lamani
Ramesh Lamani

Reputation: 1127

Issue is resolved, actually i have written in code console.log(something);. In IE9 it wont recognize this is causing the problem. Now it is working very nicely. so it means dont have to keep console.log() in code.

Upvotes: 0

Related Questions