How You Pass Login Parameters

These examples show how to generate a form to pass login parameters to B2C Service.

Using these examples, you can retain all query_string parameters and append key-value pair parameters.

Replacing certain variables with meaningful values will make the scripts easier for you to understand.

  • your_domain: the domain name used by your B2C Service site

  • your_interface: your interface name

  • li_password: the string specified in the PTA_SECRET_KEY configuration setting

Caution: This example code snippet is for illustrative purposes only and will be improperly formatted if you attempt to cut and paste directly from it.
<?
//Assumption is that user has been validated/logged in and you have their contact record
//available and can access their profile data
//Build up PTA data array
$ptaDataArray = array(

//Common contact fields (not a complete listing, this is just a sampling)
//The $contact variable is assumed to be the data of the user logging in
'p_userid'     => $contact->login,
'p_passwd'     => $contact->password,

//Only needs to be sent if PTA_IGNORE_CONTACT_PASSWORD is disabled
'p_email.addr' => $contact->emailAddress,
'p_name.first' => $contact->firstName,
'p_name.last'  => $contact->lastName,

//Example of sending in custom field value where the custom field 
ID is 3 'p_ccf_3'      => $contact->customField3Value,

//Example of sending in channel field value where the channel field ID is 14
'p_chan_14'    => $contact->channelField14Value);

//Add secret key if not using encryption
if (PTA_ENCRYPTION_METHOD configuration setting IS NOT set)
{
$ptaDataArray['p_li_passwd'] = Value of PTA_SECRET_KEY config setting;
}

//Convert PTA data array to string
$ptaDataString = "";
foreach($ptaData as $key=>$value)
{
$ptaDataString .= ($ptaDataString === "") ? '' : '&';
    $ptaDataString .= "$key=$value";
}

//Optionally encrypt data if using encryption with the method, secret key, padding a keygen
//methods. The function called here is made up. The actual function will vary depending on
//which language you are using
if (PTA_ENCRYPTION_METHOD IS set)
{
$ptaDataString = encryptData($ptaDataString, PTA_ENCRYPTION_METHOD, 
PTA_SECRET_KEY, PTA_ENCRYPTION_PADDING, PTA_ENCRYPTION_KEYGEN);
}

//Base64 encode the data
$ptaDataString = base64_encode($ptaDataString);

//Make sure the data is URL safe
$ptaDataString = strtr($ptaDataString, array('+' => '_', '/' =>
'~', '='                         => '*'));

//Specify which page to take the user to
if (%next_page% URL parameter exists)
$redirectPage = %next_page% parameter;
else
$redirectPage = 'home';

//Send the user to the PTA controller to log them in
header("Location: http://your _CP_site/ci/pta/login/redirect/$redirectPage/p_li/$ptaDataString");
exit;