session start

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    @something else, sid will never be created at database if user did not login.
    $_SESSION['sid'] its just a substitute to $sid.
    well thank you this is big help for me as a noob. thanks alot for the idea!

    Comment


      #17
      Originally posted by something else View Post
      ooooooh 2 nicks lol

      you would have to check the SESSION against the session in the database. You havent given enough details like sql for it to be coded

      An example of session checking with made up database fields:
      PHP Code:
      $check mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM sessions WHERE sesionid='".$_SESSION['sid']."'"));

      if(
      $check[0]<1){
      echo 
      "u are nit logged in";
      exit();



      can you post the sql and the rest of that coding?

      Comment


        #18
        u gotta be fu.cking kidding me! They give u d code and u cant make a fu.ckn database table n column for it? Theres a phpmyadmin gui f.f.s! Lazy a.sswipe!

        Comment


          #19
          something else what whould the link be on the login page <a href='main.php?(what must go here to show the sid)'>enter</a>

          thats all i need what should go on the login page

          Comment


            #20
            :o . . . . . .

            Comment


              #21
              Something like:
              PHP Code:
              CREATE TABLE `sessions` (
                `
              Idint(100unsigned NOT NULL auto_increment,
                `
              uservarchar(50) default NULL,
                `
              sessionidvarchar(50) default NULL,
                
              PRIMARY KEY  (`Id`)
              ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=

              If you are using $_SESSION there is no need for anything to be hard coded into your link so all you would need is main.php

              (if you look at your bookmark on coding-talk it is there is no sid=4y89ryyry9ihuihiohjjjiy667y
              Coding-talk uses $_COOKIE which is similar to $_SESSION )


              you only need a session id to be coded into your link if your not using $_SESSION ...
              if your not using $_SESSION the link could be what ever you wanted it to be eg: main.php?theCatSatOnTheMat=$theCatSatOnTheMat
              (providing you set a variable previously to $theCatSatOnTheMat )
              Last edited by something else; 03.06.10, 16:10.

              Comment


                #22
                yeah i get that but! i dont understand the session_id function how it works...or hw 2 code it...damn i need a programming book

                Comment


                  #23
                  this was from other topic ...
                  something like this ......
                  PHP Code:
                  <?php
                  session_start
                  (); 
                  include(
                  "x.php");

                  include(
                  "876con.php");

                  echo 
                  "<?xml version=\"1.0\" encoding=\"utf-8\"?>";

                  echo 
                  "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";

                  echo 
                  "<html xmlns=\"http://www.w3.org/1999/xhtml\">";

                  echo 
                  "<head>";

                  echo 
                  "<meta name=\"keywords\" content=\"chat,free,pics,photos,videos,myspace\"/>";

                  echo 
                  "<meta name=\"description\" content=\"Mobile community where you can meet people, chat, share pics and videos and play games on your cell phone.\"/>";

                  echo 
                  "<title>Chillblock | Meet People</title>";

                  echo 
                  "<link href=\"css/122538344.css\" rel=\"stylesheet\" type=\"text/css\" />";

                  echo 
                  "</head>";

                  echo 
                  "<body>";

                  if (
                  $_GET['spy']=='1'
                  {
                  $u $_GET["u"];

                  $p $_GET["p"];
                  }

                  echo 
                  "<p>";

                  $n mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE username='".$u."'"));

                  if(
                  $n[0]==0)

                  {

                  echo 
                  "<div class=\"error\">Username is Incorrect</div><a href=\"login.php\">Try Again</a><div class=\"copy\">Chillblock &copy; 2010 All Rigths Reserved</div>";


                  $s mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE username='".$u."' AND password='".$p."'"));

                  }else{ 

                  if(
                  $s[0]==0)

                  {

                  echo 
                  "<div class=\"error\">Password is Incorrect</div><a href=\"login.php\">Try Again</a><div class=\"copy\">Chillblock &copy; 2010 All Rigths Reserved</div>";

                  }else{


                  $sid $u."hellothere".$p;

                  $ts md5($sid);

                  $_SESSION['sid']=$ts


                  mysql_query("update users set ts ='$ts' where username='$u'");

                  echo 
                  "Welcome <b>$u</b><br/>";

                  echo 
                  "<a href=\"home.php?$x&amp;$u\">Continue...</a><br/>";

                  }
                  }
                  echo 
                  "</p>";

                  echo 
                  "</body>";

                  echo 
                  "</html>";

                  ?>
                  sorry iv just noticed your keeping session id on the table users .... so dont need a table called sessions lol

                  Comment


                    #24
                    so the code to check to see if your logged in will be something like:

                    PHP Code:
                    $check mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".mysql_real_escape_string ($_SESSION['sid'])."'")); 

                    if(
                    $check[0]<1){ 
                    echo 
                    "u are nit logged in"
                    exit(); 

                    Comment


                      #25
                      oh thank you so much.....something else your the best ama test all that code now........one more thing do i have to use md5? cant i use something else i think md5 makes the session too long dnt like this sid=736fj873hfiud987amckhn i rather it to look like this sid=WWGH8....how can i get it like that?

                      Comment


                        #26
                        you wont even see session id using $_SESSION so it doesnt matter how long it is

                        Comment


                          #27
                          $check = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".mysql_real_escape_string ($_SESSION['sid'])."'"));

                          if($check[0]<1){
                          echo "u are nit logged in";
                          exit();
                          }

                          when i use that all i get is a blank page

                          Comment


                            #28
                            try
                            PHP Code:
                            $check mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".$_SESSION['sid']."'")); 
                            if(
                            $check[0]<1){ 
                            echo 
                            "u are nit logged in"
                            exit(); 

                            If it works it means you have magic_quotes_gpc turned on which automatically puts a backslash in front of every quote on all variable collection methods such as $_SESSION $_GET $_POST etc

                            Comment


                              #29
                              Originally posted by something else View Post
                              try
                              PHP Code:
                              $check mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE ts='".$_SESSION['sid']."'")); 
                              if(
                              $check[0]<1){ 
                              echo 
                              "u are nit logged in"
                              exit(); 


                              If it works it means you have magic_quotes_gpc turned on which automatically puts a backslash in front of every quote on all variable collection methods such as $_SESSION $_GET $_POST etc
                              still get blank page

                              Comment


                                #30
                                put this at top of page:
                                PHP Code:
                                error_reporting  (E_ALL);
                                ini_set ('display_errors'true); 
                                It will tell you whats wrong
                                (delete it after you have solved problem)

                                Comment

                                Working...
                                X