News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

I need some help with cookies

Started by DigiMajik, June 23, 2007, 12:06:55 AM

Previous topic - Next topic

DigiMajik

I'm trying to write a download manager for my web site. The only issue I have right now is that I need a way to set and get the user information out of a cookie.

I found a some code on the boards that lets me create a login page that accurately logs in a user and creates a cookie for them, but I need to be able to read from the cookie itself so that members don't have to put in their username and password every time they want to upload a file. I need it so that once they log into the boards or the download manager that it sets and reads the cookie correctly.

Can someone please tell me how to read the cookie I just created or at least read the board cookie so that I can put that into my code? Thanks.

codenaught

I can be more detailed if need be, but I would first recommend looking at how SMF handles cookies at login. Check the function Login2() in Sources/LogInOut.php. Notice the use of the unserialize function, the use of the $_COOKIE super global. And to see how cookies are set you can take a look at setLoginCookie in Subs-Auth.php (although it sounds like you already know how to set a cookie).
Dev Consultant
Former SMF Doc Coordinator

DigiMajik


DigiMajik

Update:

That worked perfectly. Thanks!


Advertisement: