Undefined index: my_accessToken

#1

this is my code

<?php
	session_start();
	
	$accessToken = $_SESSION['my_accessToken'];
?>

and this is the error
image

#2

set the token first before trying to use it.

#3

How would I do that? I am trying to connect it with github API, OAuth

Access token is unique each time right? All I have is public and secret IDs.

Here is full code from the index.php

<?php
	session_start();
	
	$accessToken = $_SESSION['my_accessToken'];
?>
<html>
<body>

<?php
	if ($accessToken != "") {
		echo '<p>loggedin</p>';
	} else {
		echo '<p><a href ="https://github.com/login/oauth/authorize?client_id=70ad6e323f9e5dadb65c">signin</a></p>';
	}
?>
</body>
</html>

This then goes to a callback(callback.php) once the user login via github

Sorry but this is the first time for me trying out OAuth

#4

You are trying to use the value without checking to see if it exists.

1 Like