We help IT Professionals succeed at work.

Set session/cookie using onClick

clearchannel
clearchannel asked
on
1,402 Views
Last Modified: 2008-02-01
I need to set a session variable and or a cookie when a user clicks on a link or an image, but I do not want to reload the page due to the querystring I need to keep active.

Thanks
Comment
Watch Question

Author

Commented:
I am guessing this is not as simple as it I thought. :(

Commented:
No it is not.

You can set a cookie by javascript. Setting a cookie (and a session variable) with ASP requires that you need to load a page. Of course you can load a page with an onclick. But if you want to prevent the current page to reload, you'll need to do a hidden request. Such as httpxmlrequest with javascript.

Author

Commented:
OK so going via the httpxmlrequest method what is my best option for achieving it?

Commented:
Just request an asp page, it does not even need to have any output, as long as it changes the session. If any output, it would be useful to indicate success or failure. A simple "0" or "1" is enough.

As for the cookie, I would also use javascript. I am not sure if a cookie set on a httpxmlrequest will be set in the browser as well. Although that is easy to find out (and maybe someone will know).

Author

Commented:
I think you are missing the point; I need to know the scripting to get this working please.

Author

Commented:
Or a javascript to set a cookie which I can then set the seesion variable form!
System Architect, CF programmer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.