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
brainsharkbrainshark 

Ajax login

Is it possible to initiate a session using an existing session id?

It seems like the beta version of the toolkit allowed you to do that while the release version requires you to call login(username, password) before you can call the api using javascript.

I have a page on my own server that needs to interact with the API. I have the server url and the session id so I'd like to be able to use those to initiate the session. Will connection.js handle it? Do I need to set a certain javascript variable to my session?

Thanks!
cheenathcheenath
You can set the sessionId on connection:

sforce.connection.sessionId = "your session id";



BAGELBAGEL
If you are loading the "/soap/ajax/8.0/connection.js" on your own server, what is the domain for this? Or saving connection.js on your own server? I suppose that won't work right?


brainsharkbrainshark
Well... to answer your first question: Since I'm loading it on my own server, the domain will be my own. Let's say www.example.com. Obviously, at that point I would have to have the .js file on my system.

Alternatively, I can also load the connection.js file from salesforce.com since I do have the right url -- na1.salesforce.com etc... (like I mentioned in my post)...

So, why do you suppose taht won't work? I must be missing something...
BAGELBAGEL
Did you get it working for you? I am running into some problem with the latest FireFox and IE7.
This is what I am trying to do:

I have a s-control loading a webpage from my webserver (using html/javascrpt, not php, so I need to use ajax api) On my page, I am trying to access a custom object, modify it, save it back. With the previous version of IE and Firefox, I can make it work by playing around with the security setting. However, with the new version of IE and Firefox, I get error loading it.

For IE, I get an "object error"
For Firefox, I get "TypeError: node.nodeName has no properties"

Any ideas?
brainsharkbrainshark
To be honest, I haven't actually tried it. I resorted to doing it server-side.

How are you "loading a webpage" from your server with an s-control? Why do you need to do that? Can't you do everything inside the s-control?
BAGELBAGEL
For security reason, we need to do that from our server. Hmm.. so you have not tried it? I wondering if anyone have an idea.
brainsharkbrainshark
You didn't answer my question as to how you're loading the page. If it's iframe etc.. then you'd get cross-domain errors

If you're trying to do it with ajax, it makes no difference as to where the javascript code lives in terms of security...