Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP
please a example
how to work a session in php?
Posted 27-May-12 6:58am
Comments
enhzflep at 27-May-12 13:25pm
   
This tute includes a section on Sessions.
http://edrackham.com/php/php-login-script-tutorial/
Ruard at 27-May-12 20:28pm
   
Go to php.net, an excellent website for php coders.
 
For info about sessions: http://nl3.php.net/manual/en/book.session.php
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Simple instructions:
1. In every page you will have to start session with session_start function.
2. To get and set session use $_SESSION array variable, its global.
3. If you want to completely remove a session variable use unset function.
4. Finally if you want to clear session, may be after sign out use session_close function.
 
Beside these above instruction follow google/w3school/php.net and so on
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Pandvi at 27-May-12 23:54pm
   
Good! +5
Prasad_Kulkarni at 27-May-12 23:58pm
   
Thanks Pandvi!
spk89 at 27-May-12 23:57pm
   
My 5!
Prasad_Kulkarni at 27-May-12 23:58pm
   
Thanks spk!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Comments
Prasad_Kulkarni at 27-May-12 23:58pm
   
Good links too! +5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

<?php
 
    session_start();
    //$_SESSION['name']="dsg";
    //unset($_SESSION['name']);

    session_destroy();
 
    ?>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6


$name='admin';
 
$_SESSION['name']=$name;
 
For Destroying session
 
session_destroy();
 

?>
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

If you want to use sessions in your php at the starting line you have to write
 
session_start();
?>
 
Mainly we are using sessions for storing some information to next php files
session_start();
$id='kishore@id'
$_SESSION['user_id']=$id;
?>
Now in any php you can use this user_id by using php like
session_start();
// Now if you want to search by using the login user id then you can directly access that value

$uid=$_SESSION['user_id'];
?>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 540
1 CPallini 290
2 OriginalGriff 265
3 ChauhanAjay 124
4 George Jonsson 120
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 10 Apr 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100