Cookies and session in php

45 Views Asked by At

If I write this code

session_start();
set_cookie('firstname','alice',time()+3600);
$_SESSION['firstname']='alice';
print_r($_SESSION['firstname']);
print_r($_COOKIE['firstname']);

This program prints only the session variable and not the cookie variable. Why is it so? Thanks for helping!

0

There are 0 best solutions below