Sessions and Cookies

I currently have a website that allows my visitors to register through a simple script that I inserted together and wrote. Currently, I use sessions only to register visitors. Are there any advantages to adding cookies to my website in order to maintain my registered user status?

Or is there a better way at all?

using PHP

+5
source share
3 answers

@Ramiro Gonzalez Maciel he said he made this script, he doesn’t need frameworks for an example. Typically, structures have scripts wrapped up and well placed.

To answer this question:

cookie md5, md5 () , , tim -, ,

:

<?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    // sql and escape stuff witch will return 1 if he has entered a valid login
    if($sqlreturn == 1){
       // do login
       $wraplogin = md5($username."-".md5($password)."-".SECRET_KEY); // I always define a define('SECRET_KEY', 'mysecretkey'); in global file.
       // now you can store that $wraplogin in cookies and remember his login. Next time he enters the website, you read that cookie, compare it with what you have in your database and let him in.
    }
?>

, , ( > 500 000 ), :)

cookie .

.

+3

PHP-, cookie. PHP cookie -.

+4

- (Java Servlets ) cookie ; URL. , - -, , cookie . Web Framework Session . , cookie , , Session , Session persistence.

, " " "rembember me", - , Session, . , cookie " " , , . (: )

, , -, cookie.

+1

All Articles