function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SpectorSpector 

Simple Question - Session Variables?

Sorry if this question seems remedial, but I can't seem to find the answer anywhere...

I have a set of VisualForce pages that make calls to a 3rd party web service that I wrote. This web service requires a "key" that is retrieved by calling the "Login()" function on the web service. This function sends back a string that should be used with all subsequent calls to this web service. My question is, is there some equivalent of session variables I can use in Apex to store this variable? I would like some variable I can set that will live as long as the SF user is logged in, and should only be accessible by that SF user.

Thanks,
Spector


Message Edited by Spector on 10-03-2008 04:12 PM
kyleRochekyleRoche
Does it just need to be stored while they are interacting w/ these three pages? If they leave the set of pages (back to some normal SFDC page) and return can you reset the variable again?

Is it a value that should not be accessible to an admin user? How private is it?

There's a few options for storing data 'like' a session... although, there's no notion of session yet. Can you give a bit more detail?
David VPDavid VP


Your best bet is probably to store the session key in a custom field on the user's profile.



David
Andrew8230Andrew8230
David VP, how would you do that in the user's profile?
David VPDavid VP
Just create a custom field e.g. 'ExternalSessionKey' on the user object and set it's security so that only the user can see this. Whenever a user calls the login function, get the external website's sessionkey, store it in that custom field on the user object.

You can then use it whenever you need in VF pages or apex code that is run by that user. (take a look at the UserInfo class, this will allow you to see in apex which user is in context).


-David