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 8212367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:43:53+00:00 2026-06-07T10:43:53+00:00

After a successful login attempt my php script starts a session like this: session_set_cookie_params(1800,’/’,’www.mydomain.com’,true);

  • 0

After a successful login attempt my php script starts a session like this:

    session_set_cookie_params(1800,'/','www.mydomain.com',true);
    session_start();
    header("location:mainpage.html");

Now my questions are:

  • How can I save my user-id to my session for further use?
  • Would it be sufficient to add these 3 code snippet to keep my sessions alive in a jQuery Mobile page:

mysession.php:

     <?php
     session_set_cookie_params(1800,'/','www.mydomain.com',true);
     session_start();
     ?>

somewhere in mainpage.html:

    function getHttpRequestObj()
    {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            return new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    function callSession(id)
    {
    var xmlhttp = getHttpRequestObj();
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById(id).innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","mysession.php",true);
    xmlhttp.send();
    }

And then in the outmost div (name=’main’) in mainpage.html

      $(document).ready(function() {
callSession('main');
});
  • 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-07T10:43:54+00:00Added an answer on June 7, 2026 at 10:43 am

    Problem solved by adding the following code at the top of my mainpage.html and renaming it to mainpage.php

    <?php
    session_start();
    $id = $_SESSION['id'];
    ?>
    

    Now I can access my userid from anywhere by doing

    <? echo $id ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A session is being passed after successful login from a aspx page to an
I'm wondering if regenerating the session id after a successful login really a good
My question of the day is this. After a successful login I want to
Currently after successful login I add md5($username) md5($password) in cookies and then every time
After a successful start of Tomcat and a few REST calls I get this
After a successful login via Devise, how can I redirect the user back to
I'm using lightopenid as the login system for a site and after successful login,
Trying to redirect users to their associated 'home' page after successful login w/out nil'ing
On iOS (or any mobile), after a successful login, how should I handle login
I have one application where after successful Login user will be redirected to Home.aspx.

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.