I have string variable and array in my page. I want to pass these variables to another pages. For string variable yes I can use querystring but for array what can I do?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
localStorage can only handle strings which is why you have to first convert your array into a string before storing it.
Like others have said the above only works with modern browsers so if you are worried about browser compatibility you can store your array in a cookie.
If you have concerns regarding size restrictions of cookies and the size of your array check out this question