• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Insert And Retrieve Data in MySQL with $.post Noob Question

Composer Warning: openssl extension is missing. How to enable in WAMP

Read users and passwords from a txt file

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

Laravel display validation error

I'm trying to use curl with php but getting this error:Could not resolve host: Bearer

hidden INPUT value not available in $_POST

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

401 Unauthorized only occurring on some pages in Laravel 8

Transfer data between JavaScript and PHP through JSON

Sentry on Symfony: how to exclude `NotFoundHttpException`

Increase value by 1 on button click

Laravel/docker-compose/redis - Class 'Redis' not found

Group data in a multidimensional array based on two columns

How to get transaction details in notify_url page in paypal

About Contact Privacy policy Terms and conditions