How can we create a session in PHP?

0 votes
I want to track each user whenever they logged in into my application. How can we track that?

Thank you!!
Mar 27 in PHP by kartik
• 10,990 points
33 views

1 answer to this question.

0 votes

Hello @kartik,

session_start() function is used in PHP to create a session.

Sample code:

session_start(); //Start session

$_SESSION['USERNAME']='Fahmida'; //Set a session value

unset($_SESSION['USERNAME']; //delete session value

The above code will enable to create session for each user that logged into your application

Thank you!!

answered Mar 27 by Niroj
• 22,110 points

Related Questions In PHP

0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19 in PHP by Niroj
• 22,110 points
68 views
0 votes
1 answer

How can we avoid my php form from hacking?

Hii @kartik, If you want to know php ...READ MORE

answered Feb 13 in PHP by Niroj
• 22,110 points
62 views
0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered Feb 13 in PHP by Niroj
• 22,110 points
106 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27 in PHP by Niroj
• 22,110 points
40 views
0 votes
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 22,110 points
417 views
0 votes
1 answer

What is type casting and type juggling in php?

Hey, The way by which PHP can assign ...READ MORE

answered Mar 27 in PHP by Niroj
• 22,110 points
48 views
0 votes
1 answer

What is the use of $_REQUEST variable in php?

Hii @kartik, The $_REQUEST variable is used to read the ...READ MORE

answered Mar 27 in PHP by Niroj
• 22,110 points
49 views
0 votes
1 answer

How to clone a JavaScript object?

Hello, You can clone an object and remove ...READ MORE

answered Apr 2 in Java-Script by Niroj
• 22,110 points
15 views
0 votes
1 answer

How can we track Google Analytics on a redirection page with PHP?

Hello @kartik, Since the page that is sending ...READ MORE

answered Apr 29 in PHP by Niroj
• 22,110 points
37 views
0 votes
1 answer

How can I expire a PHP session after 50 minutes?

Hii @kartik, Use the session_set_cookie_paramsfunciton for make this. Is necessary ...READ MORE

answered May 19 in PHP by Niroj
• 22,110 points
25 views