I have been trying to figure this one out for a few hours. I have a database of users in which I use MySQL to connect with. I receive the username and access level of the user successfully. This information is sent / stored in a cookie. The way that I extract data from a cookie is through Javascript. What I need to do is declare a php variable as the access level value from the cookie. In other words, how do you declare a php variable using a javascript variable?
Hi!
I don't this this is possible. The only way I can figure this out is by redirecting the browser to ex.: http://www.void.com/file.php?ID=x through JavaScript, where the X is defined in the cookie, and then later in file.php interpreted by Php.
Hope this helps.
When setting the cookie for the username & password also set a cookie for the access level. This cookie will then be sent back to you on subsequent requests.
Note: Although the way you are doing this will work, it is not secure!
Jack
I'm pretty sure it is secure...
The username and password are checked before any cookies are sent. The system isn't solely based upon the cookie for authentication. It is a combination between php/mysql checking and the cookie saving correct information.