Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:07:02+00:00 2026-06-18T15:07:02+00:00

$_SESSION[‘user_id’] = $login; setcookie(‘user_id’, ‘$login’ , time()+86000); header(‘Location: userindex.php’); function logged_in() { return (isset($_SESSION[‘user_id’])

  • 0
$_SESSION['user_id'] = $login;  
setcookie('user_id', '$login' , time()+86000);
header('Location: userindex.php');

function logged_in() {
return (isset($_SESSION['user_id']) || isset($_COOKIE['user_id']) ? true : false;
}

I have SESSION but I wonna include COOKIE too but I don’t know how to restart SESSION with COOKIE. I don’t have a idea how I can get that. I create COOKIE but can’t logout and have problem with SESSION somebody can help me to fix my problem???? And in every page on top I have logged_in function for check if user is logged in or not I wonna these logged_in function to check if user has cookie to auto login to user cookie. I think it is in logged_in function must get write some code and…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:07:04+00:00Added an answer on June 18, 2026 at 3:07 pm

    I will note that this is not secure, as any one can create the cookie, using something like firebug.

    @session_start();
    
    function logged_in() {
        if(!isset($_SESSION['user_id']) && isset($_COOKIE['user_id'])) {
            $_SESSION['user_id'] = $_COOKIE['user_id'];
        }
        return isset($_SESSION['user_id']);
    }
    
    function logout() {
        unset($_SESSION['user_id']);
        setcookie("user_id", "", time() - 3600);
        header("Location: http://".$_SERVER['HTTP_HOST']);
        exit;
    }
    

    Edit: Added logout() – will remove both session and cookie ‘user_id’, then redirect to homepage

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$_session['user_id']=4; Where this values of session is saved.. means in some file?? where??
My session variables are empty when I login users and use a header redirect.
session_1.php <?php session_start(); $_SESSION[0]['uid'] = 1; $_SESSION[0]['uname'] = n1; $_SESSION[1]['uid'] = 2; $_SESSION[1]['uname'] =
session_start() should be the first line of web page. Dreamweaver's php templates should be
session_start(); //login page if(mysql_num_rows($result) != '0'){ // If match. session_register(username); // Craete session username.
session_start(); $_SESSION['user'] = 789456; $_SESSION['name'] = dummy; $_SESSION['id'] = 123; print_r($_SESSION); session_destroy(); echo Session
Why session.createCriteria(classtype).list() return more object than in list ? Returned list is contains repeating
On session timeout we re-direct to the login page and if the user logs
session_start(); $_SESSION['fname']=$row['fname']; $_SESSION['user']=$row['name']; $_SESSION['adpoint'] = $row['adpoint']; $_SESSION['phone']=$row['phone']; $_SESSION['id'] = $row['id']; $_SESSION['rememberMe'] = $_POST['rememberMe']; //
I have a session variable that I set like this: <?php $token = md5(uniqid(rand(),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.