I am storing a cookie with multiple values from an asp.net page (VB). I am then trying to retrieve the values from the cookie in PHP and can't find a way to get the multiple values using PHP
$myRole is only returning "R" not "admin"
php full cookie var_dump($myCookie); is string(48) "Role=admin&User=myuser&Time=3/8/2017 8:08:43 PM"
ASP.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sb As New StringBuilder()
Dim cookie As HttpCookie
cookie = Request.Cookies.Get("PHPAUTH")
If (cookie Is Nothing) Then
sb.Append("Cookie was not received from the client. ")
sb.Append("Creating cookie to add to the response. <br/>")
cookie = New HttpCookie("PHPAUTH")
If Not Roles.IsUserInRole(User.Identity.Name, "admin") Then
'cookie.Values("Role") = "not in role"
Else
cookie.Values("Role") = "admin"
cookie.Values("User") = User.Identity.Name
End If
cookie.Values("Time") = DateTime.Now.ToString()
cookie.Expires = DateTime.Now.AddMinutes(10D)
Response.Cookies.Add(cookie)
Else
sb.Append("Cookie retrieved from client. <br/>")
sb.Append("Cookie Name: " + cookie.Name + "<br/>")
sb.Append("Cookie User: " + cookie.Values("User") + "<br/>")
sb.Append("Cookie Role: " + cookie.Values("Role") + "<br/>")
sb.Append("Cookie Time: " + cookie.Values("Time") + "<br/>")
sb.Append("Cookie Expiration Date: " & _
cookie.Expires.ToString() & "<br/>")
End If
Label1.Text = sb.ToString()
End Sub
PHP:
$myCookie = $_COOKIE["PHPAUTH"];
$myRole = $myCookie["Role"];
var_dump($myCookie);
var_dump($myRole);
var_dump($_COOKIE["PHPAUTH"]);return? If it's empty, your cookie isn't getting set.echo "<pre/>";print_r($_COOKIE);at php end?$myCookie