0

I have website A i need to pass info to website B.

website A a user is logged in, using the current session on website A i will collect UserID from the session and i want to post UserID and UniID=3 to a data structure on website B that will store the data in variables that can be used in a post query from website B

I was thinking of using simple JavaScript like (on website A)

<div id="linkto"> <p>www.websiteb.com/&uniId=3 <P></div>

$('linkto').on('click',function(event){

UserId['UserId'] = $UserId 
$(post).(url'www.websiteb.com', data );

});

then collecting the UserID and UniID somehow and then using them as variables in a post query

My question is this the correct way of going about it, I basically need to collect UserID from one website and use it on another website

Beep
  • 2,559
  • 6
  • 27
  • 71
  • Take a look at [this answer](http://stackoverflow.com/a/2138534/387194) you only need to add `$_GET['uniId']` and `$_SESSION['UserId']` to `CURLOPT_POSTFIELDS` – jcubic Oct 13 '16 at 10:10
  • Thanks, ill have a look at it. im a bit lost on the best way to do this and where to start. thanks for the help – Beep Oct 13 '16 at 10:15

2 Answers2

0

Ok, I think I may have solved it.

Website A

<script language="JavaScript">

JSarray = new Array();
JSarray[0] = "$UserId";
JSarray[1] = "$var2";

function send_value(){document.myform.secret.value = JSarray.toString();}

Website B

    <?php
$secret = $_POST['secret'];
$ar=explode(',',$secret);
print_r($ar);
Beep
  • 2,559
  • 6
  • 27
  • 71
0

You could also just set up the link like you have www.websiteb.com?&uniId=3. One you get to website B you covert uniId in a session and than redirect to the URL with out the uniId in the URL. This way you now have it as a session.

<?php 
session_start();
$_SESSION['unvId'] = $_GET['unvId'];

header('Location: http://websiteb.com');
Jeff
  • 290
  • 1
  • 8
  • Hey @Jeff this may be a better idea, so I would need to send with my javascrip, then in the post action send to www.websiteb.com?&uniId=3 ? I understand your idea but am a bit lost on how to do this – Beep Oct 13 '16 at 13:30
  • I do not know how you are presenting the uniId on the page but it could be as easy as www.websiteb.com&uniId=. – Jeff Oct 13 '16 at 14:42