banner image
What is session ?

1. Session is used to store and pass the information within site from login in website to logout of website

2. Session plays important role in webiste.

3. Once session created and it can be used multiple time in your website project

4. In simple words any website or web application dont know who you are , so how it know who you are ?, By means of session this issuse is solved. while you are login into any website it ask for your username and password which is uniquely defined in that website database while you creating an account, so once you login successfully at that time wesbite session is created and you do any changes or query in that website all changes are made saved by your username or user id in its database table.
example : Many people uses the facebook everybody posting init , but facebook never open others facebook account,  it open those account only which  accounts username and password is given.

Session creating syntax :

1. Session creating for Associative array :

        $define_array=array(
                                          "username"=>"Mahesh",
                                          "login_email"=>"kannolimahesh@gmail.com"
                                         );

        $this->session->set_userdata($define_array);

2.  Session creating for single array :


         $this->session->set_userdata('mobile_number','123456789');

Session removing syntax :

1. Session removing for Associative array 
     unset(
        $_SESSION['username'],
        $_SESSION['login_email']
       ); 

2. Session removing for single array
    unset($_SESSION['mobile_number']);



 



Reviewed by Admin on April 01, 2020 Rating: 5

No comments:

Powered by Blogger.