Hello!
I want to continue a session even after the browser was closed. What I want to do is to remember the host, username, password, of mysql. Whats the trick?

Hello!
I want to continue a session even after the browser was closed. What I want to do is to remember the host, username, password, of mysql. Whats the trick?

You could store a cookie. It basically means constructing a small part of the session like logic yourself. Create an md5 hash. Pass that on to the client as a cookie. Create a file with the md5 hash plus some prefix and extension as the filename and then put the details you want to store in there.

Of course you can use a DB as an alternative storage method for your special session.
Another option is to pass the session-ID to the client as a cookie and extend the session timeout to a very long time (lets say a month).

Member Avatar for P0lT10n

You can store it in a coockie...

setcookie("name","value",expiration)

and for read it

$_COOKIE["name"]

You can store it in a coockie...

setcookie("name","value",expiration)

and for read it

$_COOKIE["name"]

So now you have some code that shows how to do it. I would recommend not to store passwords in cookies. The problem with that is twofold: the password is transmitted in clear text on every call to a page on that site (regardless of whether or not it uses the cookies or not) and problem 2, the password is stored in clear text in the cookie files on the client PC without any real protection. Therefore I would really just store some unique session key inside the cookie and store the details on the server side in a place that is indexed using this cookie value.

My 2 Ct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.